Skip to content

Commit 56478c8

Browse files
committed
[phalcon/incubator#971] Mass unification to collectionsManager
1 parent 6cd967c commit 56478c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+106
-114
lines changed

README.md

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Manager controls the initialization of collections, keeping record of relations
3131
use Phalcon\Incubator\MongoDB\Mvc\Collection\Manager;
3232

3333
$di->set(
34-
'collectionManager',
34+
'collectionsManager',
3535
function () {
3636
return new Manager();
3737
}
@@ -72,68 +72,60 @@ $robots = RobotsCollection::find();
7272
echo "There are ", count($robots), "\n";
7373

7474
// How many mechanical robots are there?
75-
$robots = RobotsCollection::find(
76-
[
77-
[
78-
"type" => "mechanical",
79-
],
80-
]
81-
);
75+
$robots = RobotsCollection::find([
76+
[
77+
"type" => "mechanical",
78+
],
79+
]);
8280

8381
echo "There are ", count(robots), "\n";
8482

8583
// Get and print virtual robots ordered by name
86-
$robots = RobotsCollection::findFirst(
87-
[
88-
[
89-
"type" => "virtual"
90-
],
91-
"order" => [
92-
"name" => 1,
93-
],
94-
]
95-
);
84+
$robots = RobotsCollection::findFirst([
85+
[
86+
"type" => "virtual",
87+
],
88+
"order" => [
89+
"name" => 1,
90+
],
91+
]);
9692

9793
foreach ($robots as $robot) {
98-
echo $robot->name, "\n";
94+
echo $robot->name, "\n";
9995
}
10096

10197
// Get first 100 virtual robots ordered by name
102-
$robots = RobotsCollection::find(
103-
[
104-
[
105-
"type" => "virtual",
106-
],
107-
"order" => [
108-
"name" => 1,
109-
],
110-
"limit" => 100,
111-
]
112-
);
98+
$robots = RobotsCollection::find([
99+
[
100+
"type" => "virtual",
101+
],
102+
"order" => [
103+
"name" => 1,
104+
],
105+
"limit" => 100,
106+
]);
113107

114108
foreach (RobotsCollection as $robot) {
115-
echo $robot->name, "\n";
109+
echo $robot->name, "\n";
116110
}
117111

118-
$robot = RobotsCollection::findFirst(
119-
[
120-
[
121-
"_id" => new ObjectId("45cbc4a0e4123f6920000002"),
122-
],
123-
]
124-
);
112+
$robot = RobotsCollection::findFirst([
113+
[
114+
"_id" => new ObjectId("45cbc4a0e4123f6920000002"),
115+
],
116+
]);
125117

126118
// Find robot by using \MongoDB\BSON\ObjectId object
127119
$robot = RobotsCollection::findById(
128-
new ObjectId("545eb081631d16153a293a66")
120+
new ObjectId("545eb081631d16153a293a66")
129121
);
130122

131123
// Find robot by using id as sting
132124
$robot = RobotsCollection::findById("45cbc4a0e4123f6920000002");
133125

134126
// Validate input
135127
if ($robot = RobotsCollection::findById($_POST["id"])) {
136-
// ...
128+
// ...
137129
}
138130
```
139131

src/Mvc/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ public static function findById($id): ?CollectionInterface
849849
$className = static::class;
850850
$collection = new $className();
851851

852-
if ($collection->getCollectionManager()->isUsingImplicitObjectIds($collection)) {
852+
if ($collection->getCollectionsManager()->isUsingImplicitObjectIds($collection)) {
853853
$objectId = new ObjectId($id);
854854
} else {
855855
$objectId = $id;
@@ -870,7 +870,7 @@ public static function findById($id): ?CollectionInterface
870870
*
871871
* @return ManagerInterface
872872
*/
873-
public function getCollectionManager(): ManagerInterface
873+
public function getCollectionsManager(): ManagerInterface
874874
{
875875
return $this->collectionsManager;
876876
}
@@ -1243,10 +1243,10 @@ public function unserialize($data): void
12431243
/**
12441244
* Gets the default collectionsManager service
12451245
*/
1246-
$manager = $container->getShared("collectionManager");
1246+
$manager = $container->getShared('collectionsManager');
12471247
if ($manager === null) {
12481248
throw new Exception(
1249-
"The injected service 'collectionManager' is not valid"
1249+
"The injected service 'collectionsManager' is not valid"
12501250
);
12511251
}
12521252

src/Mvc/Collection/Manager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
* These components control the initialization of collections, keeping record of relations
2929
* between the different collections of the application.
3030
*
31-
* A CollectionManager is injected to a collection via a Dependency Injector Container such as Phalcon\Di.
31+
* A CollectionsManager is injected to a collection via a Dependency Injector Container such as Phalcon\Di.
3232
*
3333
* <code>
3434
* $di = new \Phalcon\Di();
3535
*
3636
* $di->set(
37-
* "collectionManager",
37+
* "collectionsManager",
3838
* function () {
3939
* return new \Phalcon\Incubator\MongoDB\Mvc\Collection\Manager();
4040
* }
@@ -181,7 +181,7 @@ public function initialize(CollectionInterface $collection): void
181181
* If an EventsManager is available we pass to it every initialized collection
182182
*/
183183
if (is_object($this->eventsManager)) {
184-
$this->eventsManager->fire('collectionManager:afterInitialize', $collection);
184+
$this->eventsManager->fire('collectionsManager:afterInitialize', $collection);
185185
}
186186

187187
$this->initialized[$className] = $collection;

src/Mvc/Collection/ManagerInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
* These components control the initialization of collections, keeping record of relations
2222
* between the different collections of the application.
2323
*
24-
* A CollectionManager is injected to a collection via a Dependency Injector Container such as Phalcon\Di.
24+
* A CollectionsManager is injected to a collection via a Dependency Injector Container such as Phalcon\Di.
2525
*
2626
* <code>
2727
* $di = new \Phalcon\Di\Di();
2828
*
2929
* $di->set(
30-
* "collectionManager",
30+
* "collectionsManager",
3131
* function() {
3232
* return new \Phalcon\Incubator\Mvc\Collection\Manager();
3333
* }

tests/_data/fixtures/Traits/DiTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Phalcon\Di\Di;
1818
use Phalcon\Di\DiInterface;
1919
use Phalcon\Di\FactoryDefault;
20-
use Phalcon\Incubator\MongoDB\Mvc\Collection\Manager as CollectionManager;
20+
use Phalcon\Incubator\MongoDB\Mvc\Collection\Manager as CollectionsManager;
2121

2222
trait DiTrait
2323
{
@@ -53,11 +53,11 @@ protected function resetDi()
5353
}
5454

5555
/**
56-
* Setup a new Collection Manager
56+
* Set up a new Collection Manager
5757
*/
58-
protected function setDiCollectionManager()
58+
protected function setDiCollectionsManager()
5959
{
60-
$this->container->setShared('collectionsManager', CollectionManager::class);
60+
$this->container->setShared('collectionsManager', CollectionsManager::class);
6161
}
6262

6363
/**

tests/integration/Collection/AggregateCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AggregateCest
3232
public function _before()
3333
{
3434
$this->setNewFactoryDefault();
35-
$this->setDiCollectionManager();
35+
$this->setDiCollectionsManager();
3636
$this->setDiMongo();
3737

3838
$this->source = (new Robots())->getSource();

tests/integration/Collection/AppendMessageCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AppendMessageCest
2626
public function _before()
2727
{
2828
$this->setNewFactoryDefault();
29-
$this->setDiCollectionManager();
29+
$this->setDiCollectionsManager();
3030
$this->setDiMongo();
3131
}
3232

tests/integration/Collection/AssignCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AssignCest
2525
public function _before()
2626
{
2727
$this->setNewFactoryDefault();
28-
$this->setDiCollectionManager();
28+
$this->setDiCollectionsManager();
2929
$this->setDiMongo();
3030
}
3131

tests/integration/Collection/CloneResultCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CloneResultCest
3232
public function _before()
3333
{
3434
$this->setNewFactoryDefault();
35-
$this->setDiCollectionManager();
35+
$this->setDiCollectionsManager();
3636
$this->setDiMongo();
3737

3838
$this->source = (new Robots)->getSource();

tests/integration/Collection/ConstructCest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ConstructCest
2525
public function _before()
2626
{
2727
$this->setNewFactoryDefault();
28-
$this->setDiCollectionManager();
28+
$this->setDiCollectionsManager();
2929
$this->setDiMongo();
3030
}
3131

0 commit comments

Comments
 (0)