PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/fernandograsselli/phalcon-devtools
PHP | 388 lines | 50 code | 75 blank | 263 comment | 0 complexity | 0ad84062d7c92a67e9bd128b0ba988a1 MD5 | raw file
  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 \Phalcon\DI\InjectionAwareInterface {
  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. * @return array
  92. */
  93. public function readMetaDataIndex($model, $index){ }
  94. /**
  95. * Writes meta-data for certain model using a MODEL_* constant
  96. *
  97. *<code>
  98. * print_r($metaData->writeColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP, array('leName' => 'name')));
  99. *</code>
  100. *
  101. * @param \Phalcon\Mvc\ModelInterface $model
  102. * @param int $index
  103. * @param mixed $data
  104. */
  105. public function writeMetaDataIndex($model, $index, $data, $replace){ }
  106. /**
  107. * Reads the ordered/reversed column map for certain model
  108. *
  109. *<code>
  110. * print_r($metaData->readColumnMap(new Robots()));
  111. *</code>
  112. *
  113. * @param \Phalcon\Mvc\ModelInterface $model
  114. * @return array
  115. */
  116. public function readColumnMap($model){ }
  117. /**
  118. * Reads column-map information for certain model using a MODEL_* constant
  119. *
  120. *<code>
  121. * print_r($metaData->readColumnMapIndex(new Robots(), MetaData::MODELS_REVERSE_COLUMN_MAP));
  122. *</code>
  123. *
  124. * @param \Phalcon\Mvc\ModelInterface $model
  125. * @param int $index
  126. */
  127. public function readColumnMapIndex($model, $index){ }
  128. /**
  129. * Returns table attributes names (fields)
  130. *
  131. *<code>
  132. * print_r($metaData->getAttributes(new Robots()));
  133. *</code>
  134. *
  135. * @param \Phalcon\Mvc\ModelInterface $model
  136. * @return array
  137. */
  138. public function getAttributes($model){ }
  139. /**
  140. * Returns an array of fields which are part of the primary key
  141. *
  142. *<code>
  143. * print_r($metaData->getPrimaryKeyAttributes(new Robots()));
  144. *</code>
  145. *
  146. * @param \Phalcon\Mvc\ModelInterface $model
  147. * @return array
  148. */
  149. public function getPrimaryKeyAttributes($model){ }
  150. /**
  151. * Returns an arrau of fields which are not part of the primary key
  152. *
  153. *<code>
  154. * print_r($metaData->getNonPrimaryKeyAttributes(new Robots()));
  155. *</code>
  156. *
  157. * @param \Phalcon\Mvc\ModelInterface $model
  158. * @return array
  159. */
  160. public function getNonPrimaryKeyAttributes($model){ }
  161. /**
  162. * Returns an array of not null attributes
  163. *
  164. *<code>
  165. * print_r($metaData->getNotNullAttributes(new Robots()));
  166. *</code>
  167. *
  168. * @param \Phalcon\Mvc\ModelInterface $model
  169. * @return array
  170. */
  171. public function getNotNullAttributes($model){ }
  172. /**
  173. * Returns attributes and their data types
  174. *
  175. *<code>
  176. * print_r($metaData->getDataTypes(new Robots()));
  177. *</code>
  178. *
  179. * @param \Phalcon\Mvc\ModelInterface $model
  180. * @return array
  181. */
  182. public function getDataTypes($model){ }
  183. /**
  184. * Returns attributes which types are numerical
  185. *
  186. *<code>
  187. * print_r($metaData->getDataTypesNumeric(new Robots()));
  188. *</code>
  189. *
  190. * @param \Phalcon\Mvc\ModelInterface $model
  191. * @return array
  192. */
  193. public function getDataTypesNumeric($model){ }
  194. /**
  195. * Returns the name of identity field (if one is present)
  196. *
  197. *<code>
  198. * print_r($metaData->getIdentityField(new Robots()));
  199. *</code>
  200. *
  201. * @param \Phalcon\Mvc\ModelInterface $model
  202. * @return string
  203. */
  204. public function getIdentityField($model){ }
  205. /**
  206. * Returns attributes and their bind data types
  207. *
  208. *<code>
  209. * print_r($metaData->getBindTypes(new Robots()));
  210. *</code>
  211. *
  212. * @param \Phalcon\Mvc\ModelInterface $model
  213. * @return array
  214. */
  215. public function getBindTypes($model){ }
  216. /**
  217. * Returns attributes that must be ignored from the INSERT SQL generation
  218. *
  219. *<code>
  220. * print_r($metaData->getAutomaticCreateAttributes(new Robots()));
  221. *</code>
  222. *
  223. * @param \Phalcon\Mvc\ModelInterface $model
  224. * @return array
  225. */
  226. public function getAutomaticCreateAttributes($model){ }
  227. /**
  228. * Returns attributes that must be ignored from the UPDATE SQL generation
  229. *
  230. *<code>
  231. * print_r($metaData->getAutomaticUpdateAttributes(new Robots()));
  232. *</code>
  233. *
  234. * @param \Phalcon\Mvc\ModelInterface $model
  235. * @return array
  236. */
  237. public function getAutomaticUpdateAttributes($model){ }
  238. /**
  239. * Set the attributes that must be ignored from the INSERT SQL generation
  240. *
  241. *<code>
  242. * $metaData->setAutomaticCreateAttributes(new Robots(), array('created_at' => true));
  243. *</code>
  244. *
  245. * @param \Phalcon\Mvc\ModelInterface $model
  246. * @param array $attributes
  247. */
  248. public function setAutomaticCreateAttributes($model, $attributes, $replace){ }
  249. /**
  250. * Set the attributes that must be ignored from the UPDATE SQL generation
  251. *
  252. *<code>
  253. * $metaData->setAutomaticUpdateAttributes(new Robots(), array('modified_at' => true));
  254. *</code>
  255. *
  256. * @param \Phalcon\Mvc\ModelInterface $model
  257. * @param array $attributes
  258. */
  259. public function setAutomaticUpdateAttributes($model, $attributes, $replace){ }
  260. /**
  261. * Returns the column map if any
  262. *
  263. *<code>
  264. * print_r($metaData->getColumnMap(new Robots()));
  265. *</code>
  266. *
  267. * @param \Phalcon\Mvc\ModelInterface $model
  268. * @return array
  269. */
  270. public function getColumnMap($model){ }
  271. /**
  272. * Returns the reverse column map if any
  273. *
  274. *<code>
  275. * print_r($metaData->getReverseColumnMap(new Robots()));
  276. *</code>
  277. *
  278. * @param \Phalcon\Mvc\ModelInterface $model
  279. * @return array
  280. */
  281. public function getReverseColumnMap($model){ }
  282. /**
  283. * Check if a model has certain attribute
  284. *
  285. *<code>
  286. * var_dump($metaData->hasAttribute(new Robots(), 'name'));
  287. *</code>
  288. *
  289. * @param \Phalcon\Mvc\ModelInterface $model
  290. * @param string $attribute
  291. * @return boolean
  292. */
  293. public function hasAttribute($model, $attribute){ }
  294. /**
  295. * Checks if the internal meta-data container is empty
  296. *
  297. *<code>
  298. * var_dump($metaData->isEmpty());
  299. *</code>
  300. *
  301. * @return boolean
  302. */
  303. public function isEmpty(){ }
  304. /**
  305. * Resets internal meta-data in order to regenerate it
  306. *
  307. *<code>
  308. * $metaData->reset();
  309. *</code>
  310. */
  311. public function reset(){ }
  312. }
  313. }