PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/vendor/phalcon/devtools/ide/2.0.7/Phalcon/mvc/Collection.php

https://gitlab.com/habracoder/advertising
PHP | 509 lines | 62 code | 74 blank | 373 comment | 0 complexity | 09f4d42f8f8e1349deeeef11547612d9 MD5 | raw file
  1. <?php
  2. namespace Phalcon\Mvc;
  3. /**
  4. * Phalcon\Mvc\Collection
  5. * This component implements a high level abstraction for NoSQL databases which
  6. * works with documents
  7. */
  8. abstract class Collection implements \Phalcon\Mvc\EntityInterface, \Phalcon\Mvc\CollectionInterface, \Phalcon\Di\InjectionAwareInterface, \Serializable
  9. {
  10. const OP_NONE = 0;
  11. const OP_CREATE = 1;
  12. const OP_UPDATE = 2;
  13. const OP_DELETE = 3;
  14. protected $_id;
  15. protected $_dependencyInjector;
  16. protected $_modelsManager;
  17. protected $_source;
  18. protected $_operationMade = 0;
  19. protected $_connection;
  20. protected $_errorMessages;
  21. static protected $_reserved;
  22. static protected $_disableEvents;
  23. protected $_skipped = false;
  24. /**
  25. * Phalcon\Mvc\Collection constructor
  26. *
  27. * @param mixed $dependencyInjector
  28. * @param mixed $modelsManager
  29. */
  30. public final function __construct(\Phalcon\DiInterface $dependencyInjector = null, \Phalcon\Mvc\Collection\ManagerInterface $modelsManager = null) {}
  31. /**
  32. * Sets a value for the _id property, creates a MongoId object if needed
  33. *
  34. * @param mixed $id
  35. */
  36. public function setId($id) {}
  37. /**
  38. * Returns the value of the _id property
  39. *
  40. * @return \MongoId
  41. */
  42. public function getId() {}
  43. /**
  44. * Sets the dependency injection container
  45. *
  46. * @param mixed $dependencyInjector
  47. */
  48. public function setDI(\Phalcon\DiInterface $dependencyInjector) {}
  49. /**
  50. * Returns the dependency injection container
  51. *
  52. * @return \Phalcon\DiInterface
  53. */
  54. public function getDI() {}
  55. /**
  56. * Sets a custom events manager
  57. *
  58. * @param mixed $eventsManager
  59. */
  60. protected function setEventsManager(\Phalcon\Mvc\Collection\ManagerInterface $eventsManager) {}
  61. /**
  62. * Returns the custom events manager
  63. *
  64. * @return \Phalcon\Mvc\Collection\ManagerInterface
  65. */
  66. protected function getEventsManager() {}
  67. /**
  68. * Returns the models manager related to the entity instance
  69. *
  70. * @return \Phalcon\Mvc\Collection\ManagerInterface
  71. */
  72. public function getCollectionManager() {}
  73. /**
  74. * Returns an array with reserved properties that cannot be part of the insert/update
  75. *
  76. * @return array
  77. */
  78. public function getReservedAttributes() {}
  79. /**
  80. * Sets if a model must use implicit objects ids
  81. *
  82. * @param bool $useImplicitObjectIds
  83. */
  84. protected function useImplicitObjectIds($useImplicitObjectIds) {}
  85. /**
  86. * Sets collection name which model should be mapped
  87. *
  88. * @param string $source
  89. * @return Collection
  90. */
  91. protected function setSource($source) {}
  92. /**
  93. * Returns collection name mapped in the model
  94. *
  95. * @return string
  96. */
  97. public function getSource() {}
  98. /**
  99. * Sets the DependencyInjection connection service name
  100. *
  101. * @param string $connectionService
  102. * @return Collection
  103. */
  104. public function setConnectionService($connectionService) {}
  105. /**
  106. * Returns DependencyInjection connection service
  107. *
  108. * @return string
  109. */
  110. public function getConnectionService() {}
  111. /**
  112. * Retrieves a database connection
  113. *
  114. * @return \MongoDb
  115. */
  116. public function getConnection() {}
  117. /**
  118. * Reads an attribute value by its name
  119. * <code>
  120. * echo $robot->readAttribute('name');
  121. * </code>
  122. *
  123. * @param string $attribute
  124. * @return mixed
  125. */
  126. public function readAttribute($attribute) {}
  127. /**
  128. * Writes an attribute value by its name
  129. * <code>
  130. * $robot->writeAttribute('name', 'Rosey');
  131. * </code>
  132. *
  133. * @param string $attribute
  134. * @param mixed $value
  135. */
  136. public function writeAttribute($attribute, $value) {}
  137. /**
  138. * Returns a cloned collection
  139. *
  140. * @param mixed $collection
  141. * @param array $document
  142. * @return CollectionInterface
  143. */
  144. public static function cloneResult(CollectionInterface $collection, $document) {}
  145. /**
  146. * Returns a collection resultset
  147. *
  148. * @param array $params
  149. * @param \Phalcon\Mvc\Collection $collection
  150. * @param \MongoDb $connection
  151. * @param boolean $unique
  152. * @return array
  153. */
  154. protected static function _getResultset($params, CollectionInterface $collection, $connection, $unique) {}
  155. /**
  156. * Perform a count over a resultset
  157. *
  158. * @param array $params
  159. * @param \Phalcon\Mvc\Collection $collection
  160. * @param \MongoDb $connection
  161. * @return int
  162. */
  163. protected static function _getGroupResultset($params, Collection $collection, $connection) {}
  164. /**
  165. * Executes internal hooks before save a document
  166. *
  167. * @param \Phalcon\DiInterface $dependencyInjector
  168. * @param boolean $disableEvents
  169. * @param boolean $exists
  170. * @return boolean
  171. */
  172. protected final function _preSave($dependencyInjector, $disableEvents, $exists) {}
  173. /**
  174. * Executes internal events after save a document
  175. *
  176. * @param bool $disableEvents
  177. * @param bool $success
  178. * @param bool $exists
  179. * @return bool
  180. */
  181. protected final function _postSave($disableEvents, $success, $exists) {}
  182. /**
  183. * Executes validators on every validation call
  184. * <code>
  185. * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
  186. * class Subscriptors extends \Phalcon\Mvc\Collection
  187. * {
  188. * public function validation()
  189. * {
  190. * this->validate(new ExclusionIn(array(
  191. * 'field' => 'status',
  192. * 'domain' => array('A', 'I')
  193. * )));
  194. * if (this->validationHasFailed() == true) {
  195. * return false;
  196. * }
  197. * }
  198. * }
  199. * </code>
  200. *
  201. * @param mixed $validator
  202. */
  203. protected function validate(Model\ValidatorInterface $validator) {}
  204. /**
  205. * Check whether validation process has generated any messages
  206. * <code>
  207. * use Phalcon\Mvc\Model\Validator\ExclusionIn as ExclusionIn;
  208. * class Subscriptors extends \Phalcon\Mvc\Collection
  209. * {
  210. * public function validation()
  211. * {
  212. * this->validate(new ExclusionIn(array(
  213. * 'field' => 'status',
  214. * 'domain' => array('A', 'I')
  215. * )));
  216. * if (this->validationHasFailed() == true) {
  217. * return false;
  218. * }
  219. * }
  220. * }
  221. * </code>
  222. *
  223. * @return bool
  224. */
  225. public function validationHasFailed() {}
  226. /**
  227. * Fires an internal event
  228. *
  229. * @param string $eventName
  230. * @return bool
  231. */
  232. public function fireEvent($eventName) {}
  233. /**
  234. * Fires an internal event that cancels the operation
  235. *
  236. * @param string $eventName
  237. * @return bool
  238. */
  239. public function fireEventCancel($eventName) {}
  240. /**
  241. * Cancel the current operation
  242. *
  243. * @param bool $disableEvents
  244. * @return bool
  245. */
  246. protected function _cancelOperation($disableEvents) {}
  247. /**
  248. * Checks if the document exists in the collection
  249. *
  250. * @param \MongoCollection $collection
  251. * @return boolean
  252. */
  253. protected function _exists($collection) {}
  254. /**
  255. * Returns all the validation messages
  256. * <code>
  257. * $robot = new Robots();
  258. * $robot->type = 'mechanical';
  259. * $robot->name = 'Astro Boy';
  260. * $robot->year = 1952;
  261. * if ($robot->save() == false) {
  262. * echo "Umh, We can't store robots right now ";
  263. * foreach ($robot->getMessages() as message) {
  264. * echo message;
  265. * }
  266. * } else {
  267. * echo "Great, a new robot was saved successfully!";
  268. * }
  269. * </code>
  270. *
  271. * @return \Phalcon\Mvc\Model\MessageInterface
  272. */
  273. public function getMessages() {}
  274. /**
  275. * Appends a customized message on the validation process
  276. * <code>
  277. * use \Phalcon\Mvc\Model\Message as Message;
  278. * class Robots extends \Phalcon\Mvc\Model
  279. * {
  280. * public function beforeSave()
  281. * {
  282. * if ($this->name == 'Peter') {
  283. * message = new Message("Sorry, but a robot cannot be named Peter");
  284. * $this->appendMessage(message);
  285. * }
  286. * }
  287. * }
  288. * </code>
  289. *
  290. * @param mixed $message
  291. */
  292. public function appendMessage(\Phalcon\Mvc\Model\MessageInterface $message) {}
  293. /**
  294. * Creates/Updates a collection based on the values in the attributes
  295. *
  296. * @return bool
  297. */
  298. public function save() {}
  299. /**
  300. * Find a document by its id (_id)
  301. *
  302. * @param string|\MongoId $id
  303. * @return \Phalcon\Mvc\Collection
  304. */
  305. public static function findById($id) {}
  306. /**
  307. * Allows to query the first record that match the specified conditions
  308. * <code>
  309. * //What's the first robot in the robots table?
  310. * $robot = Robots::findFirst();
  311. * echo "The robot name is ", $robot->name, "\n";
  312. * //What's the first mechanical robot in robots table?
  313. * $robot = Robots::findFirst(array(
  314. * array("type" => "mechanical")
  315. * ));
  316. * echo "The first mechanical robot name is ", $robot->name, "\n";
  317. * //Get first virtual robot ordered by name
  318. * $robot = Robots::findFirst(array(
  319. * array("type" => "mechanical"),
  320. * "order" => array("name" => 1)
  321. * ));
  322. * echo "The first virtual robot name is ", $robot->name, "\n";
  323. * </code>
  324. *
  325. * @param array $parameters
  326. * @return array
  327. */
  328. public static function findFirst($parameters = null) {}
  329. /**
  330. * Allows to query a set of records that match the specified conditions
  331. * <code>
  332. * //How many robots are there?
  333. * $robots = Robots::find();
  334. * echo "There are ", count($robots), "\n";
  335. * //How many mechanical robots are there?
  336. * $robots = Robots::find(array(
  337. * array("type" => "mechanical")
  338. * ));
  339. * echo "There are ", count(robots), "\n";
  340. * //Get and print virtual robots ordered by name
  341. * $robots = Robots::findFirst(array(
  342. * array("type" => "virtual"),
  343. * "order" => array("name" => 1)
  344. * ));
  345. * foreach ($robots as $robot) {
  346. * echo $robot->name, "\n";
  347. * }
  348. * //Get first 100 virtual robots ordered by name
  349. * $robots = Robots::find(array(
  350. * array("type" => "virtual"),
  351. * "order" => array("name" => 1),
  352. * "limit" => 100
  353. * ));
  354. * foreach ($robots as $robot) {
  355. * echo $robot->name, "\n";
  356. * }
  357. * </code>
  358. *
  359. * @param array $parameters
  360. * @return array
  361. */
  362. public static function find($parameters = null) {}
  363. /**
  364. * Perform a count over a collection
  365. * <code>
  366. * echo 'There are ', Robots::count(), ' robots';
  367. * </code>
  368. *
  369. * @param array $parameters
  370. * @return array
  371. */
  372. public static function count($parameters = null) {}
  373. /**
  374. * Perform an aggregation using the Mongo aggregation framework
  375. *
  376. * @param array $parameters
  377. * @return array
  378. */
  379. public static function aggregate($parameters = null) {}
  380. /**
  381. * Allows to perform a summatory group for a column in the collection
  382. *
  383. * @param string $field
  384. * @param mixed $conditions
  385. * @param mixed $finalize
  386. * @return array
  387. */
  388. public static function summatory($field, $conditions = null, $finalize = null) {}
  389. /**
  390. * Deletes a model instance. Returning true on success or false otherwise.
  391. * <code>
  392. * $robot = Robots::findFirst();
  393. * $robot->delete();
  394. * foreach (Robots::find() as $robot) {
  395. * $robot->delete();
  396. * }
  397. * </code>
  398. *
  399. * @return bool
  400. */
  401. public function delete() {}
  402. /**
  403. * Sets up a behavior in a collection
  404. *
  405. * @param mixed $behavior
  406. */
  407. protected function addBehavior(\Phalcon\Mvc\Collection\BehaviorInterface $behavior) {}
  408. /**
  409. * Skips the current operation forcing a success state
  410. *
  411. * @param bool $skip
  412. */
  413. public function skipOperation($skip) {}
  414. /**
  415. * Returns the instance as an array representation
  416. * <code>
  417. * print_r($robot->toArray());
  418. * </code>
  419. *
  420. * @return array
  421. */
  422. public function toArray() {}
  423. /**
  424. * Serializes the object ignoring connections or protected properties
  425. *
  426. * @return string
  427. */
  428. public function serialize() {}
  429. /**
  430. * Unserializes the object from a serialized string
  431. *
  432. * @param string $data
  433. */
  434. public function unserialize($data) {}
  435. }