PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/ide/0.9.0/Phalcon/Mvc/Model/MetaData.php

https://github.com/AntonShevchuk/phalcon-devtools
PHP | 387 lines | 50 code | 75 blank | 262 comment | 0 complexity | 3ad8f99d97ec16dc494f7bafe5a9c91d MD5 | raw file
Possible License(s): BSD-3-Clause, MIT
  1. <?php
  2. namespace Phalcon\Mvc\Model {
  3. /**
  4. * Phalcon\Mvc\Model\MetaData
  5. *
  6. * <p>Because Phalcon\Mvc\Model requires meta-data like field names, data types, primary keys, etc.
  7. * this component collect them and store for further querying by Phalcon\Mvc\Model.
  8. * Phalcon\Mvc\Model\MetaData can also use adapters to store temporarily or permanently the meta-data.</p>
  9. *
  10. * <p>A standard Phalcon\Mvc\Model\MetaData can be used to query model attributes:</p>
  11. *
  12. * <code>
  13. * $metaData = new Phalcon\Mvc\Model\MetaData\Memory();
  14. * $attributes = $metaData->getAttributes(new Robots());
  15. * print_r($attributes);
  16. * </code>
  17. *
  18. */
  19. abstract class MetaData implements MetaDataInterface {
  20. const MODELS_ATTRIBUTES = 0;
  21. const MODELS_PRIMARY_KEY = 1;
  22. const MODELS_NON_PRIMARY_KEY = 2;
  23. const MODELS_NOT_NULL = 3;
  24. const MODELS_DATA_TYPES = 4;
  25. const MODELS_DATA_TYPES_NUMERIC = 5;
  26. const MODELS_DATE_AT = 6;
  27. const MODELS_DATE_IN = 7;
  28. const MODELS_IDENTITY_COLUMN = 8;
  29. const MODELS_DATA_TYPES_BIND = 9;
  30. const MODELS_AUTOMATIC_DEFAULT_INSERT = 10;
  31. const MODELS_AUTOMATIC_DEFAULT_UPDATE = 11;
  32. const MODELS_COLUMN_MAP = 0;
  33. const MODELS_REVERSE_COLUMN_MAP = 1;
  34. protected $_dependencyInjector;
  35. protected $_strategy;
  36. protected $_metaData;
  37. protected $_columnMap;
  38. /**
  39. * Initialize the metadata for certain table
  40. *
  41. * @param \Phalcon\Mvc\ModelInterface $model
  42. * @param string $key
  43. * @param string $table
  44. * @param string $schema
  45. */
  46. protected function _initialize(){ }
  47. /**
  48. * Sets the DependencyInjector container
  49. *
  50. * @param \Phalcon\DiInterface $dependencyInjector
  51. */
  52. public function setDI($dependencyInjector){ }
  53. /**
  54. * Returns the DependencyInjector container
  55. *
  56. * @return \Phalcon\DiInterface
  57. */
  58. public function getDI(){ }
  59. /**
  60. * Set the meta-data extraction strategy
  61. *
  62. * @param \Phalcon\Mvc\Model\MetaData\Strategy\Introspection $strategy
  63. */
  64. public function setStrategy($strategy){ }
  65. /**
  66. * Return the strategy to obtain the meta-data
  67. *
  68. * @return \Phalcon\Mvc\Model\MetaData\Strategy\Introspection
  69. */
  70. public function getStrategy(){ }
  71. /**
  72. * Reads the complete meta-data for certain model
  73. *
  74. *<code>
  75. * print_r($metaData->readMetaData(new Robots());
  76. *</code>
  77. *
  78. * @param \Phalcon\Mvc\ModelInterface $model
  79. * @return array
  80. */
  81. public function readMetaData($model){ }
  82. /**
  83. * Reads meta-data for certain model using a MODEL_* constant
  84. *
  85. *<code>
  86. * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
  87. *</code>
  88. *
  89. * @param \Phalcon\Mvc\ModelInterface $model
  90. * @param int $index
  91. */
  92. public function readMetaDataIndex($model, $index){ }
  93. /**
  94. * Writes meta-data for certain model using a MODEL_* constant
  95. *
  96. *<code>
  97. * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
  98. *</code>
  99. *
  100. * @param \Phalcon\Mvc\ModelInterface $model
  101. * @param int $index
  102. * @param mixed $data
  103. */
  104. public function writeMetaDataIndex($model, $index, $data){ }
  105. /**
  106. * Reads the ordered/reversed column map for certain model
  107. *
  108. *<code>
  109. * print_r($metaData->readColumnMap(new Robots()));
  110. *</code>
  111. *
  112. * @param \Phalcon\Mvc\ModelInterface $model
  113. * @return array
  114. */
  115. public function readColumnMap($model){ }
  116. /**
  117. * Reads column-map information for certain model using a MODEL_* constant
  118. *
  119. *<code>
  120. * print_r($metaData->readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP));
  121. *</code>
  122. *
  123. * @param \Phalcon\Mvc\ModelInterface $model
  124. * @param int $index
  125. */
  126. public function readColumnMapIndex($model, $index){ }
  127. /**
  128. * Returns table attributes names (fields)
  129. *
  130. *<code>
  131. * print_r($metaData->getAttributes(new Robots()));
  132. *</code>
  133. *
  134. * @param \Phalcon\Mvc\ModelInterface $model
  135. * @return array
  136. */
  137. public function getAttributes($model){ }
  138. /**
  139. * Returns an array of fields which are part of the primary key
  140. *
  141. *<code>
  142. * print_r($metaData->getPrimaryKeyAttributes(new Robots()));
  143. *</code>
  144. *
  145. * @param \Phalcon\Mvc\ModelInterface $model
  146. * @return array
  147. */
  148. public function getPrimaryKeyAttributes($model){ }
  149. /**
  150. * Returns an arrau of fields which are not part of the primary key
  151. *
  152. *<code>
  153. * print_r($metaData->getNonPrimaryKeyAttributes(new Robots()));
  154. *</code>
  155. *
  156. * @param \Phalcon\Mvc\ModelInterface $model
  157. * @return array
  158. */
  159. public function getNonPrimaryKeyAttributes($model){ }
  160. /**
  161. * Returns an array of not null attributes
  162. *
  163. *<code>
  164. * print_r($metaData->getNotNullAttributes(new Robots()));
  165. *</code>
  166. *
  167. * @param \Phalcon\Mvc\ModelInterface $model
  168. * @return array
  169. */
  170. public function getNotNullAttributes($model){ }
  171. /**
  172. * Returns attributes and their data types
  173. *
  174. *<code>
  175. * print_r($metaData->getDataTypes(new Robots()));
  176. *</code>
  177. *
  178. * @param \Phalcon\Mvc\ModelInterface $model
  179. * @return array
  180. */
  181. public function getDataTypes($model){ }
  182. /**
  183. * Returns attributes which types are numerical
  184. *
  185. *<code>
  186. * print_r($metaData->getDataTypesNumeric(new Robots()));
  187. *</code>
  188. *
  189. * @param \Phalcon\Mvc\ModelInterface $model
  190. * @return array
  191. */
  192. public function getDataTypesNumeric($model){ }
  193. /**
  194. * Returns the name of identity field (if one is present)
  195. *
  196. *<code>
  197. * print_r($metaData->getIdentityField(new Robots()));
  198. *</code>
  199. *
  200. * @param \Phalcon\Mvc\ModelInterface $model
  201. * @return string
  202. */
  203. public function getIdentityField($model){ }
  204. /**
  205. * Returns attributes and their bind data types
  206. *
  207. *<code>
  208. * print_r($metaData->getBindTypes(new Robots()));
  209. *</code>
  210. *
  211. * @param \Phalcon\Mvc\ModelInterface $model
  212. * @return array
  213. */
  214. public function getBindTypes($model){ }
  215. /**
  216. * Returns attributes that must be ignored from the INSERT SQL generation
  217. *
  218. *<code>
  219. * print_r($metaData->getAutomaticCreateAttributes(new Robots()));
  220. *</code>
  221. *
  222. * @param \Phalcon\Mvc\ModelInterface $model
  223. * @return array
  224. */
  225. public function getAutomaticCreateAttributes($model){ }
  226. /**
  227. * Returns attributes that must be ignored from the UPDATE SQL generation
  228. *
  229. *<code>
  230. * print_r($metaData->getAutomaticUpdateAttributes(new Robots()));
  231. *</code>
  232. *
  233. * @param \Phalcon\Mvc\ModelInterface $model
  234. * @return array
  235. */
  236. public function getAutomaticUpdateAttributes($model){ }
  237. /**
  238. * Set the attributes that must be ignored from the INSERT SQL generation
  239. *
  240. *<code>
  241. * $metaData->setAutomaticCreateAttributes(new Robots(), array('created_at' => true));
  242. *</code>
  243. *
  244. * @param \Phalcon\Mvc\ModelInterface $model
  245. * @param array $attributes
  246. */
  247. public function setAutomaticCreateAttributes($model, $attributes){ }
  248. /**
  249. * Set the attributes that must be ignored from the UPDATE SQL generation
  250. *
  251. *<code>
  252. * $metaData->setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true));
  253. *</code>
  254. *
  255. * @param \Phalcon\Mvc\ModelInterface $model
  256. * @param array $attributes
  257. */
  258. public function setAutomaticUpdateAttributes($model, $attributes){ }
  259. /**
  260. * Returns the column map if any
  261. *
  262. *<code>
  263. * print_r($metaData->getColumnMap(new Robots()));
  264. *</code>
  265. *
  266. * @param \Phalcon\Mvc\ModelInterface $model
  267. * @return array
  268. */
  269. public function getColumnMap($model){ }
  270. /**
  271. * Returns the reverse column map if any
  272. *
  273. *<code>
  274. * print_r($metaData->getReverseColumnMap(new Robots()));
  275. *</code>
  276. *
  277. * @param \Phalcon\Mvc\ModelInterface $model
  278. * @return array
  279. */
  280. public function getReverseColumnMap($model){ }
  281. /**
  282. * Check if a model has certain attribute
  283. *
  284. *<code>
  285. * var_dump($metaData->hasAttribute(new Robots(), 'name'));
  286. *</code>
  287. *
  288. * @param \Phalcon\Mvc\ModelInterface $model
  289. * @param string $attribute
  290. * @return boolean
  291. */
  292. public function hasAttribute($model, $attribute){ }
  293. /**
  294. * Checks if the internal meta-data container is empty
  295. *
  296. *<code>
  297. * var_dump($metaData->isEmpty());
  298. *</code>
  299. *
  300. * @return boolean
  301. */
  302. public function isEmpty(){ }
  303. /**
  304. * Resets internal meta-data in order to regenerate it
  305. *
  306. *<code>
  307. * $metaData->reset();
  308. *</code>
  309. */
  310. public function reset(){ }
  311. }
  312. }