mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Removed unused option triggerDisabled
from ObjectCollection::trigger().
Fixed docblock for ObjectCollection::load();
This commit is contained in:
parent
ba6f3c17fa
commit
a7d08a6b39
2 changed files with 1 additions and 32 deletions
|
@ -189,30 +189,6 @@ class ObjectCollectionTest extends CakeTestCase {
|
||||||
$this->assertTrue($this->Objects->trigger('callback'));
|
$this->assertTrue($this->Objects->trigger('callback'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* test that the initalize callback is triggered on all components even those that are disabled.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testTriggerWithTriggerDisabledObjects() {
|
|
||||||
$this->_makeMockClasses();
|
|
||||||
$this->Objects->load('TriggerMockFirst', array(), false);
|
|
||||||
$this->Objects->load('TriggerMockSecond');
|
|
||||||
|
|
||||||
$this->mockObjects[] = $this->Objects->TriggerMockFirst;
|
|
||||||
$this->mockObjects[] = $this->Objects->TriggerMockSecond;
|
|
||||||
|
|
||||||
$this->Objects->TriggerMockFirst->expects($this->once())
|
|
||||||
->method('callback')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
$this->Objects->TriggerMockSecond->expects($this->once())
|
|
||||||
->method('callback')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
$result = $this->Objects->trigger('callback', array(), array('triggerDisabled' => true));
|
|
||||||
$this->assertTrue($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test trigger and disabled objects
|
* test trigger and disabled objects
|
||||||
*
|
*
|
||||||
|
|
|
@ -42,7 +42,7 @@ abstract class ObjectCollection {
|
||||||
/**
|
/**
|
||||||
* Loads a new object onto the collection. Can throw a variety of exceptions
|
* Loads a new object onto the collection. Can throw a variety of exceptions
|
||||||
*
|
*
|
||||||
* Implementations of this class support a `$options['callbacks']` flag which enables/disables
|
* Implementations of this class support a `$options['enabled']` flag which enables/disables
|
||||||
* a loaded object.
|
* a loaded object.
|
||||||
*
|
*
|
||||||
* @param string $name Name of object to load.
|
* @param string $name Name of object to load.
|
||||||
|
@ -68,9 +68,6 @@ abstract class ObjectCollection {
|
||||||
* - `collectReturn` Set to true to collect the return of each object into an array.
|
* - `collectReturn` Set to true to collect the return of each object into an array.
|
||||||
* This array of return values will be returned from the trigger() call. Defaults to `false`.
|
* This array of return values will be returned from the trigger() call. Defaults to `false`.
|
||||||
*
|
*
|
||||||
* - `triggerDisabled` Will trigger the callback on all objects in the collection even the non-enabled
|
|
||||||
* objects. Defaults to false.
|
|
||||||
*
|
|
||||||
* - `modParams` Allows each object the callback gets called on to modify the parameters to the next object.
|
* - `modParams` Allows each object the callback gets called on to modify the parameters to the next object.
|
||||||
* Setting modParams to an integer value will allow you to modify the parameter with that index.
|
* Setting modParams to an integer value will allow you to modify the parameter with that index.
|
||||||
* Any non-null value will modify the parameter index indicated.
|
* Any non-null value will modify the parameter index indicated.
|
||||||
|
@ -93,16 +90,12 @@ abstract class ObjectCollection {
|
||||||
'break' => false,
|
'break' => false,
|
||||||
'breakOn' => false,
|
'breakOn' => false,
|
||||||
'collectReturn' => false,
|
'collectReturn' => false,
|
||||||
'triggerDisabled' => false,
|
|
||||||
'modParams' => false
|
'modParams' => false
|
||||||
),
|
),
|
||||||
$options
|
$options
|
||||||
);
|
);
|
||||||
$collected = array();
|
$collected = array();
|
||||||
$list = $this->_enabled;
|
$list = $this->_enabled;
|
||||||
if ($options['triggerDisabled'] === true) {
|
|
||||||
$list = array_keys($this->_loaded);
|
|
||||||
}
|
|
||||||
if ($options['modParams'] !== false && !isset($params[$options['modParams']])) {
|
if ($options['modParams'] !== false && !isset($params[$options['modParams']])) {
|
||||||
throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.'));
|
throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue