code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function over(?string $name = null)
{
$window = $this->getWindow();
if ($name) {
// Set name manually in case this was chained from FunctionsBuilder wrapper
$window->name($name);
}
return $this;
} | Adds an empty `OVER()` window expression or a named window expression.
@param string|null $name Window name
@return $this | over | php | cakephp/cakephp | src/Database/Expression/AggregateExpression.php | https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/AggregateExpression.php | MIT |
public function __clone()
{
foreach (['_value', '_field'] as $prop) {
if ($this->{$prop} instanceof ExpressionInterface) {
$this->{$prop} = clone $this->{$prop};
}
}
} | Create a deep clone.
Clones the field and value if they are expression objects.
@return void | __clone | php | cakephp/cakephp | src/Database/Expression/ComparisonExpression.php | https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/ComparisonExpression.php | MIT |
public function __clone()
{
if ($this->_value instanceof ExpressionInterface) {
$this->_value = clone $this->_value;
}
} | Perform a deep clone of the inner expression.
@return void | __clone | php | cakephp/cakephp | src/Database/Expression/UnaryExpression.php | https://github.com/cakephp/cakephp/blob/master/src/Database/Expression/UnaryExpression.php | MIT |
public function __construct(Driver $driver)
{
$driver->connect();
$this->_driver = $driver;
} | Constructor
This constructor will connect the driver so that methods like columnSql() and others
will fail when the driver has not been connected.
@param \Cake\Database\Driver $driver The driver to use. | __construct | php | cakephp/cakephp | src/Database/Schema/SchemaDialect.php | https://github.com/cakephp/cakephp/blob/master/src/Database/Schema/SchemaDialect.php | MIT |
public function __construct(iterable $items)
{
if (is_array($items)) {
$items = new ArrayIterator($items);
}
parent::__construct($items);
} | Constructor. You can provide an array or any traversable object
@param iterable $items Items.
@throws \InvalidArgumentException If passed incorrect type for items. | __construct | php | cakephp/cakephp | src/Collection/Collection.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Collection.php | MIT |
public function __construct(iterable $items, callable|string $nestKey)
{
parent::__construct($items);
$this->_nestKey = $nestKey;
} | Constructor
@param iterable $items Collection items.
@param callable|string $nestKey the property that contains the nested items
If a callable is passed, it should return the children for the passed item | __construct | php | cakephp/cakephp | src/Collection/Iterator/NestIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/NestIterator.php | MIT |
public function __construct(
RecursiveIterator $items,
callable|string $valuePath,
callable|string $keyPath,
string $spacer,
int $mode = RecursiveIteratorIterator::SELF_FIRST,
) {
parent::__construct($items, $mode);
$this->_value = $this->_propertyExtractor($valuePath);
$this->_key = $this->_propertyExtractor($keyPath);
$this->_spacer = $spacer;
} | Constructor
@param \RecursiveIterator<mixed, mixed> $items The iterator to flatten.
@param callable|string $valuePath The property to extract or a callable to return
the display value.
@param callable|string $keyPath The property to use as iteration key or a
callable returning the key value.
@param string $spacer The string to use for prefixing the values according to
their depth in the tree.
@param int $mode Iterator mode.
@phpstan-param \RecursiveIteratorIterator::LEAVES_ONLY|\RecursiveIteratorIterator::SELF_FIRST|\RecursiveIteratorIterator::CHILD_FIRST $mode | __construct | php | cakephp/cakephp | src/Collection/Iterator/TreePrinter.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/TreePrinter.php | MIT |
public function __construct(iterable $items)
{
$this->_buffer = new SplDoublyLinkedList();
parent::__construct($items);
} | Maintains an in-memory cache of the results yielded by the internal
iterator.
@param iterable $items The items to be filtered. | __construct | php | cakephp/cakephp | src/Collection/Iterator/BufferedIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/BufferedIterator.php | MIT |
public function __construct(Traversable $items, callable $unfolder)
{
$this->_unfolder = $unfolder;
parent::__construct($items);
$this->_innerIterator = $this->getInnerIterator();
} | Creates the iterator that will generate child iterators from each of the
elements it was constructed with.
@param \Traversable $items The list of values to iterate
@param callable $unfolder A callable function that will receive the
current item and key. It must return an array or Traversable object
out of which the nested iterators will be yielded. | __construct | php | cakephp/cakephp | src/Collection/Iterator/UnfoldIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/UnfoldIterator.php | MIT |
public function __construct(iterable $items, callable $condition)
{
$this->_condition = $condition;
parent::__construct($items);
$this->_innerIterator = $this->getInnerIterator();
} | Creates an iterator that can be stopped based on a condition provided by a callback.
Each time the condition callback is executed it will receive the value of the element
in the current iteration, the key of the element and the passed $items iterator
as arguments, in that order.
@param iterable $items The list of values to iterate
@param callable $condition A function that will be called for each item in
the collection, if the result evaluates to false, no more items will be
yielded from this iterator. | __construct | php | cakephp/cakephp | src/Collection/Iterator/StoppableIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/StoppableIterator.php | MIT |
public function __construct(iterable $into, string $path, iterable $values)
{
parent::__construct($into);
if (!($values instanceof Collection)) {
$values = new Collection($values);
}
$path = explode('.', $path);
$target = array_pop($path);
$this->_path = $path;
$this->_target = $target;
$this->_values = $values;
} | Constructs a new collection that will dynamically add properties to it out of
the values found in $values.
@param iterable $into The target collection to which the values will
be inserted at the specified path.
@param string $path A dot separated list of properties that need to be traversed
to insert the value into the target collection.
@param iterable $values The source collection from which the values will
be inserted at the specified path. | __construct | php | cakephp/cakephp | src/Collection/Iterator/InsertIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/InsertIterator.php | MIT |
public function __construct(iterable $items, callable $callback)
{
$this->_callback = $callback;
parent::__construct($items);
$this->_innerIterator = $this->getInnerIterator();
} | Creates an iterator from another iterator that will modify each of the values
by converting them using a callback function.
Each time the callback is executed it will receive the value of the element
in the current iteration, the key of the element and the passed $items iterator
as arguments, in that order.
@param iterable $items The items to be filtered.
@param callable $callback Callback. | __construct | php | cakephp/cakephp | src/Collection/Iterator/ReplaceIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/ReplaceIterator.php | MIT |
public function __construct(iterable $items, callable $callback)
{
if (!$items instanceof Iterator) {
$items = new Collection($items);
}
$this->_callback = $callback;
$wrapper = new CallbackFilterIterator($items, $callback);
parent::__construct($wrapper);
} | Creates a filtered iterator using the callback to determine which items are
accepted or rejected.
Each time the callback is executed it will receive the value of the element
in the current iteration, the key of the element and the passed $items iterator
as arguments, in that order.
@param iterable $items The items to be filtered.
@param callable $callback Callback. | __construct | php | cakephp/cakephp | src/Collection/Iterator/FilterIterator.php | https://github.com/cakephp/cakephp/blob/master/src/Collection/Iterator/FilterIterator.php | MIT |
public function __construct(?EventManager $eventManager = null)
{
if ($eventManager !== null) {
$this->setEventManager($eventManager);
}
$this->getEventManager()->on($this);
} | Constructor
@param \Cake\Event\EventManager|null $eventManager The event manager.
Defaults to a new instance. | __construct | php | cakephp/cakephp | src/Form/Form.php | https://github.com/cakephp/cakephp/blob/master/src/Form/Form.php | MIT |
public function unlockField(string $name)
{
if (!in_array($name, $this->unlockedFields, true)) {
$this->unlockedFields[] = $name;
}
$index = array_search($name, $this->fields, true);
if ($index !== false) {
unset($this->fields[$index]);
}
unset($this->fields[$name]);
return $this;
} | Add to the list of fields that are currently unlocked.
Unlocked fields are not included in the field hash.
@param string $name The dot separated name for the field.
@return $this | unlockField | php | cakephp/cakephp | src/Form/FormProtector.php | https://github.com/cakephp/cakephp/blob/master/src/Form/FormProtector.php | MIT |
public function removeField(string $name)
{
unset($this->_fields[$name]);
return $this;
} | Removes a field to the schema.
@param string $name The field to remove.
@return $this | removeField | php | cakephp/cakephp | src/Form/Schema.php | https://github.com/cakephp/cakephp/blob/master/src/Form/Schema.php | MIT |
public function setRequest(ServerRequest $request)
{
$this->request = $request;
$this->plugin = $request->getParam('plugin');
return $this;
} | Sets the request objects and configures a number of controller properties
based on the contents of the request. The properties that get set are:
- $this->request - To the $request parameter
- $this->plugin - To the value returned by $request->getParam('plugin')
@param \Cake\Http\ServerRequest $request Request instance.
@return $this | setRequest | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function enableAutoLayout(bool $enable = true)
{
$this->autoLayout = $enable;
return $this;
} | Turns on or off CakePHP's conventional mode of applying layout files.
On by default. Setting to off means that layouts will not be
automatically applied to rendered views.
@param bool $enable Boolean to turn on/off.
@return $this | enableAutoLayout | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function disableAutoLayout()
{
$this->autoLayout = false;
return $this;
} | Turns off CakePHP's conventional mode of applying layout files.
Layouts will not be automatically applied to rendered views.
@return $this | disableAutoLayout | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function setTemplate(string $name)
{
$this->template = $name;
return $this;
} | Set the name of the template file to render. The name specified is the
filename in `templates/<SubFolder>/` without the .php extension.
@param string $name Template file name to set.
@return $this | setTemplate | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function setLayout(string $name)
{
$this->layout = $name;
return $this;
} | Set the name of the layout file to render the template inside of.
The name specified is the filename of the layout in `templates/layout/`
without the .php extension.
@param string $name Layout file name to set.
@return $this | setLayout | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function append(string $name, mixed $value = null)
{
$this->Blocks->concat($name, $value);
return $this;
} | Append to an existing or new block.
Appending to a new block will create the block.
@param string $name Name of the block
@param mixed $value The content for the block. Value will be type cast
to string.
@return $this
@see \Cake\View\ViewBlock::concat() | append | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function prepend(string $name, mixed $value)
{
$this->Blocks->concat($name, $value, ViewBlock::PREPEND);
return $this;
} | Prepend to an existing or new block.
Prepending to a new block will create the block.
@param string $name Name of the block
@param mixed $value The content for the block. Value will be type cast
to string.
@return $this
@see \Cake\View\ViewBlock::concat() | prepend | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function assign(string $name, mixed $value)
{
$this->Blocks->set($name, $value);
return $this;
} | Set the content for a block. This will overwrite any
existing content.
@param string $name Name of the block
@param mixed $value The content for the block. Value will be type cast
to string.
@return $this
@see \Cake\View\ViewBlock::set() | assign | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function reset(string $name)
{
$this->assign($name, '');
return $this;
} | Reset the content for a block. This will overwrite any
existing content.
@param string $name Name of the block
@return $this
@see \Cake\View\ViewBlock::set() | reset | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function end()
{
$this->Blocks->end();
return $this;
} | End a capturing block. The compliment to View::start()
@return $this
@see \Cake\View\ViewBlock::end() | end | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function extend(string $name)
{
$type = str_starts_with($name, '/') ? static::TYPE_TEMPLATE : $this->_currentType;
switch ($type) {
case static::TYPE_ELEMENT:
$parent = $this->_getElementFileName($name);
if (!$parent) {
[$plugin, $name] = $this->pluginSplit($name);
$paths = $this->_paths($plugin);
$defaultPath = $paths[0] . static::TYPE_ELEMENT . DIRECTORY_SEPARATOR;
throw new LogicException(sprintf(
'You cannot extend an element which does not exist (%s).',
$defaultPath . $name . $this->_ext,
));
}
break;
case static::TYPE_LAYOUT:
$parent = $this->_getLayoutFileName($name);
break;
default:
$parent = $this->_getTemplateFileName($name);
}
if ($parent === $this->_current) {
throw new LogicException('You cannot have templates extend themselves.');
}
if (isset($this->_parents[$parent]) && $this->_parents[$parent] === $this->_current) {
throw new LogicException('You cannot have templates extend in a loop.');
}
$this->_parents[$this->_current] = $parent;
return $this;
} | Provides template or element extension/inheritance. Templates can extends a
parent template and populate blocks in the parent template.
@param string $name The template or element to 'extend' the current one with.
@return $this
@throws \LogicException when you extend a template with itself or make extend loops.
@throws \LogicException when you extend an element which doesn't exist | extend | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function setSubDir(string $subDir)
{
$this->subDir = $subDir;
return $this;
} | Set sub-directory for this template files.
@param string $subDir Sub-directory name.
@return $this
@see \Cake\View\View::$subDir
@since 3.7.0 | setSubDir | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function setElementCache(string $elementCache)
{
$this->elementCache = $elementCache;
return $this;
} | Set The cache configuration View will use to store cached elements
@param string $elementCache Cache config name.
@return $this
@see \Cake\View\View::$elementCache
@since 3.7.0 | setElementCache | php | cakephp/cakephp | src/View/View.php | https://github.com/cakephp/cakephp/blob/master/src/View/View.php | MIT |
public function setVar(string $name, mixed $value = null)
{
$this->_vars[$name] = $value;
return $this;
} | Saves a variable for use inside a template.
@param string $name A string or an array of data.
@param mixed $value Value.
@return $this | setVar | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setVars(array $data, bool $merge = true)
{
if ($merge) {
$this->_vars = $data + $this->_vars;
} else {
$this->_vars = $data;
}
return $this;
} | Saves view vars for use inside templates.
@param array<string, mixed> $data Array of data.
@param bool $merge Whether to merge with existing vars, default true.
@return $this | setVars | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function disableAutoLayout()
{
$this->_autoLayout = false;
return $this;
} | Turns off CakePHP's conventional mode of applying layout files.
Setting to off means that layouts will not be automatically applied to
rendered views.
@return $this | disableAutoLayout | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setPlugin(?string $name)
{
$this->_plugin = $name;
return $this;
} | Sets the plugin name to use.
@param string|null $name Plugin name.
Use null to remove the current plugin name.
@return $this | setPlugin | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function addHelper(string $helper, array $options = [])
{
[$plugin, $name] = pluginSplit($helper);
if ($plugin) {
$options['className'] = $helper;
}
$this->_helpers[$name] = $options;
return $this;
} | Adds a helper to use, overwriting any existing one with that name.
@param string $helper Helper to use.
@param array<string, mixed> $options Options.
@return $this
@since 4.1.0 | addHelper | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setTheme(?string $theme)
{
$this->_theme = $theme;
return $this;
} | Sets the view theme to use.
@param string|null $theme Theme name.
Use null to remove the current theme.
@return $this | setTheme | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setTemplate(?string $name)
{
$this->_template = $name;
return $this;
} | Sets the name of the view file to render. The name specified is the
filename in `templates/<SubFolder>/` without the .php extension.
@param string|null $name View file name to set, or null to remove the template name.
@return $this | setTemplate | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setLayout(?string $name)
{
$this->_layout = $name;
return $this;
} | Sets the name of the layout file to render the view inside of.
The name specified is the filename of the layout in `templates/layout/`
without the .php extension.
@param string|null $name Layout file name to set.
@return $this | setLayout | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setOptions(array $options, bool $merge = true)
{
if ($merge) {
$options += $this->_options;
}
$this->_options = $options;
return $this;
} | Sets additional options for the view.
This lets you provide custom constructor arguments to application/plugin view classes.
@param array<string, mixed> $options An array of options.
@param bool $merge Whether to merge existing data with the new data.
@return $this | setOptions | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function setClassName(?string $name)
{
$this->_className = $name;
return $this;
} | Sets the view classname.
Accepts either a short name (Ajax) a plugin name (MyPlugin.Ajax)
or a fully namespaced name (App\View\AppView) or null to use the
View class provided by CakePHP.
@param string|null $name The class name for the view.
@return $this | setClassName | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function createFromArray(array $config)
{
foreach ($config as $property => $value) {
$this->{$property} = $value;
}
return $this;
} | Configures a view builder instance from serialized config.
@param array<string, mixed> $config View builder configuration array.
@return $this | createFromArray | php | cakephp/cakephp | src/View/ViewBuilder.php | https://github.com/cakephp/cakephp/blob/master/src/View/ViewBuilder.php | MIT |
public function loadHelpers()
{
if (!$this->getConfig('serialize')) {
parent::loadHelpers();
}
return $this;
} | Load helpers only if serialization is disabled.
@return $this | loadHelpers | php | cakephp/cakephp | src/View/SerializedView.php | https://github.com/cakephp/cakephp/blob/master/src/View/SerializedView.php | MIT |
public function __construct(StringTemplate $templates, LabelWidget $label)
{
parent::__construct($templates);
$this->_label = $label;
} | Render multi-checkbox widget.
This class uses the following templates:
- `checkbox` Renders checkbox input controls. Accepts
the `name`, `value` and `attrs` variables.
- `checkboxWrapper` Renders the containing div/element for
a checkbox and its label. Accepts the `input`, and `label`
variables.
- `multicheckboxWrapper` Renders a wrapper around grouped inputs.
- `multicheckboxTitle` Renders the title element for grouped inputs.
@param \Cake\View\StringTemplate $templates Templates list.
@param \Cake\View\Widget\LabelWidget $label Label widget instance. | __construct | php | cakephp/cakephp | src/View/Widget/MultiCheckboxWidget.php | https://github.com/cakephp/cakephp/blob/master/src/View/Widget/MultiCheckboxWidget.php | MIT |
public function __construct(StringTemplate $templates)
{
$this->_templates = $templates;
} | Constructor.
This class uses the following template:
- `label` Used to generate the label for a radio button.
Can use the following variables `attrs`, `text` and `input`.
@param \Cake\View\StringTemplate $templates Templates list. | __construct | php | cakephp/cakephp | src/View/Widget/LabelWidget.php | https://github.com/cakephp/cakephp/blob/master/src/View/Widget/LabelWidget.php | MIT |
public function __construct(View $view, array $config = [])
{
parent::__construct($view, $config);
$query = $this->_View->getRequest()->getQueryParams();
unset($query['page'], $query['limit'], $query['sort'], $query['direction']);
$this->setConfig(
'options.url',
array_merge($this->_View->getRequest()->getParam('pass', []), ['?' => $query]),
);
} | Constructor. Overridden to merge passed args with URL options.
@param \Cake\View\View $view The View this helper is being attached to.
@param array<string, mixed> $config Configuration settings for the helper. | __construct | php | cakephp/cakephp | src/View/Helper/PaginatorHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/PaginatorHelper.php | MIT |
public function __construct(View $view, array $config = [])
{
$locator = null;
$widgets = $this->_defaultWidgets;
if (isset($config['locator'])) {
$locator = $config['locator'];
unset($config['locator']);
}
if (isset($config['widgets'])) {
if (is_string($config['widgets'])) {
$config['widgets'] = (array)$config['widgets'];
}
$widgets = $config['widgets'] + $widgets;
unset($config['widgets']);
}
if (isset($config['groupedInputTypes'])) {
$this->_groupedInputTypes = $config['groupedInputTypes'];
unset($config['groupedInputTypes']);
}
parent::__construct($view, $config);
if (!$locator) {
$locator = new WidgetLocator($this->templater(), $this->_View, $widgets);
}
$this->setWidgetLocator($locator);
$this->_idPrefix = $this->getConfig('idPrefix');
} | Construct the widgets and binds the default context providers
@param \Cake\View\View $view The View this helper is being attached to.
@param array<string, mixed> $config Configuration settings for the helper. | __construct | php | cakephp/cakephp | src/View/Helper/FormHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php | MIT |
public function setWidgetLocator(WidgetLocator $instance)
{
$this->_locator = $instance;
return $this;
} | Set the widget locator the helper will use.
@param \Cake\View\Widget\WidgetLocator $instance The locator instance to set.
@return $this
@since 3.6.0 | setWidgetLocator | php | cakephp/cakephp | src/View/Helper/FormHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php | MIT |
public function unlockField(string $name)
{
$this->getFormProtector()?->unlockField($name);
return $this;
} | Add to the list of fields that are currently unlocked.
Unlocked fields are not included in the form protection field hash.
It will be no-op if the FormProtectionComponent is not loaded in the controller.
@param string $name The dot separated name for the field.
@return $this | unlockField | php | cakephp/cakephp | src/View/Helper/FormHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php | MIT |
public function setValueSources(array|string $sources)
{
$sources = (array)$sources;
$this->validateValueSources($sources);
$this->_valueSources = $sources;
return $this;
} | Sets the value sources.
You need to supply one or more valid sources, as a list of strings.
Order sets priority.
@see FormHelper::$supportedValueSources for valid values.
@param array<string>|string $sources A string or a list of strings identifying a source.
@return $this
@throws \InvalidArgumentException If sources list contains invalid value. | setValueSources | php | cakephp/cakephp | src/View/Helper/FormHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php | MIT |
public function insertAt(int $index, string $title, array|string|null $url = null, array $options = [])
{
if (!isset($this->crumbs[$index]) && $index !== count($this->crumbs)) {
throw new LogicException(sprintf('No crumb could be found at index `%s`.', $index));
}
array_splice($this->crumbs, $index, 0, [compact('title', 'url', 'options')]);
return $this;
} | Insert a crumb at a specific index.
If the index already exists, the new crumb will be inserted,
before the existing element, shifting the existing element one index
greater than before.
If the index is out of bounds, an exception will be thrown.
@param int $index The index to insert at.
@param string $title Title of the crumb.
@param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
Url::build() or null / empty if the crumb does not have a link.
@param array<string, mixed> $options Array of options. These options will be used as attributes HTML attribute the crumb will
be rendered in (a <li> tag by default). It accepts two special keys:
- *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
the link)
- *templateVars*: Specific template vars in case you override the templates provided.
@return $this
@throws \LogicException In case the index is out of bound | insertAt | php | cakephp/cakephp | src/View/Helper/BreadcrumbsHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/BreadcrumbsHelper.php | MIT |
public function insertBefore(
string $matchingTitle,
string $title,
array|string|null $url = null,
array $options = [],
) {
$key = $this->findCrumb($matchingTitle);
if ($key === null) {
throw new LogicException(sprintf('No crumb matching `%s` could be found.', $matchingTitle));
}
return $this->insertAt($key, $title, $url, $options);
} | Insert a crumb before the first matching crumb with the specified title.
Finds the index of the first crumb that matches the provided class,
and inserts the supplied callable before it.
@param string $matchingTitle The title of the crumb you want to insert this one before.
@param string $title Title of the crumb.
@param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
Url::build() or null / empty if the crumb does not have a link.
@param array<string, mixed> $options Array of options. These options will be used as attributes HTML attribute the crumb will
be rendered in (a <li> tag by default). It accepts two special keys:
- *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
the link)
- *templateVars*: Specific template vars in case you override the templates provided.
@return $this
@throws \LogicException In case the matching crumb can not be found | insertBefore | php | cakephp/cakephp | src/View/Helper/BreadcrumbsHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/BreadcrumbsHelper.php | MIT |
public function insertAfter(
string $matchingTitle,
string $title,
array|string|null $url = null,
array $options = [],
) {
$key = $this->findCrumb($matchingTitle);
if ($key === null) {
throw new LogicException(sprintf('No crumb matching `%s` could be found.', $matchingTitle));
}
return $this->insertAt($key + 1, $title, $url, $options);
} | Insert a crumb after the first matching crumb with the specified title.
Finds the index of the first crumb that matches the provided class,
and inserts the supplied callable before it.
@param string $matchingTitle The title of the crumb you want to insert this one after.
@param string $title Title of the crumb.
@param array|string|null $url URL of the crumb. Either a string, an array of route params to pass to
Url::build() or null / empty if the crumb does not have a link.
@param array<string, mixed> $options Array of options. These options will be used as attributes HTML attribute the crumb will
be rendered in (a <li> tag by default). It accepts two special keys:
- *innerAttrs*: An array that allows you to define attributes for the inner element of the crumb (by default, to
the link)
- *templateVars*: Specific template vars in case you override the templates provided.
@return $this
@throws \LogicException In case the matching crumb can not be found. | insertAfter | php | cakephp/cakephp | src/View/Helper/BreadcrumbsHelper.php | https://github.com/cakephp/cakephp/blob/master/src/View/Helper/BreadcrumbsHelper.php | MIT |
public function __construct(array $context)
{
assert(
isset($context['entity']) && $context['entity'] instanceof Form,
"`\$context['entity']` must be an instance of " . Form::class,
);
$this->_form = $context['entity'];
$this->_validator = $context['validator'] ?? null;
} | Constructor.
@param array $context Context info.
Keys:
- `entity` The Form class instance this context is operating on. **(required)**
- `validator` Optional name of the validation method to call on the Form object. | __construct | php | cakephp/cakephp | src/View/Form/FormContext.php | https://github.com/cakephp/cakephp/blob/master/src/View/Form/FormContext.php | MIT |
public function __construct(array $config = [])
{
parent::__construct($config);
$this->_path = $this->getConfig('path', sys_get_temp_dir() . DIRECTORY_SEPARATOR);
if (!is_dir($this->_path)) {
mkdir($this->_path, $this->_config['dirMask'], true);
}
if (!empty($this->_config['file'])) {
$this->_file = $this->_config['file'];
if (!str_ends_with($this->_file, '.log')) {
$this->_file .= '.log';
}
}
if (!empty($this->_config['size'])) {
if (is_numeric($this->_config['size'])) {
$this->_size = (int)$this->_config['size'];
} else {
$this->_size = Text::parseFileSize($this->_config['size']);
}
}
} | Sets protected properties based on config provided
@param array<string, mixed> $config Configuration array | __construct | php | cakephp/cakephp | src/Log/Engine/FileLog.php | https://github.com/cakephp/cakephp/blob/master/src/Log/Engine/FileLog.php | MIT |
public function __construct(array $args, array $options, array $argNames)
{
$this->args = $args;
$this->options = $options;
$this->argNames = $argNames;
} | Constructor
@param array<int, array<string>|string> $args Positional arguments
@param array<string, array<string>|string|bool|null> $options Named arguments
@param array<int, string> $argNames List of argument names. Order is expected to be
the same as $args. | __construct | php | cakephp/cakephp | src/Console/Arguments.php | https://github.com/cakephp/cakephp/blob/master/src/Console/Arguments.php | MIT |
public function add(string $name, CommandInterface|string $command)
{
if (is_string($command)) {
assert(
is_subclass_of($command, CommandInterface::class),
sprintf(
'Cannot use `%s` for command `%s`. ' .
'It is not a subclass of `%s`.',
$command,
$name,
CommandInterface::class,
),
);
}
if (!preg_match('/^[^\s]+(?:(?: [^\s]+){1,2})?$/ui', $name)) {
throw new InvalidArgumentException(
"The command name `{$name}` is invalid. Names can only be a maximum of three words.",
);
}
$this->commands[$name] = $command;
return $this;
} | Add a command to the collection
@param string $name The name of the command you want to map.
@param \Cake\Console\CommandInterface|class-string<\Cake\Console\CommandInterface> $command The command to map.
Can be a FQCN or CommandInterface instance.
@return $this
@throws \InvalidArgumentException | add | php | cakephp/cakephp | src/Console/CommandCollection.php | https://github.com/cakephp/cakephp/blob/master/src/Console/CommandCollection.php | MIT |
public function remove(string $name)
{
unset($this->commands[$name]);
return $this;
} | Remove a command from the collection if it exists.
@param string $name The named shell.
@return $this | remove | php | cakephp/cakephp | src/Console/CommandCollection.php | https://github.com/cakephp/cakephp/blob/master/src/Console/CommandCollection.php | MIT |
public function __construct($stream = 'php://stdout')
{
if (is_string($stream)) {
$stream = fopen($stream, 'wb');
}
if (!is_resource($stream)) {
throw new ConsoleException('Invalid stream in constructor. It is not a valid resource.');
}
$this->_output = $stream;
if (
(
DIRECTORY_SEPARATOR === '\\' &&
!str_contains(strtolower(php_uname('v')), 'windows 10') &&
!str_contains(strtolower((string)env('SHELL')), 'bash.exe') &&
!(bool)env('ANSICON') &&
env('ConEmuANSI') !== 'ON'
) ||
(
function_exists('posix_isatty') &&
!posix_isatty($this->_output)
) ||
(
env('NO_COLOR') !== null
)
) {
$this->_outputAs = self::PLAIN;
}
} | Construct the output object.
Checks for a pretty console environment. Ansicon and ConEmu allows
pretty consoles on Windows, and is supported.
@param resource|string $stream The identifier of the stream to write output to.
@throws \Cake\Console\Exception\ConsoleException If the given stream is not a valid resource. | __construct | php | cakephp/cakephp | src/Console/ConsoleOutput.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOutput.php | MIT |
public function setEventManager(EventManagerInterface $eventManager)
{
if ($this->app instanceof EventDispatcherInterface) {
$this->app->setEventManager($eventManager);
}
return $this;
} | Get/set the application's event manager.
@param \Cake\Event\EventManagerInterface $eventManager The event manager to set.
@return $this | setEventManager | php | cakephp/cakephp | src/Console/CommandRunner.php | https://github.com/cakephp/cakephp/blob/master/src/Console/CommandRunner.php | MIT |
public function __construct(string $command = '', bool $defaultOptions = true)
{
$this->setCommand($command);
$this->addOption('help', [
'short' => 'h',
'help' => 'Display this help.',
'boolean' => true,
]);
if ($defaultOptions) {
$this->addOption('verbose', [
'short' => 'v',
'help' => 'Enable verbose output.',
'boolean' => true,
])->addOption('quiet', [
'short' => 'q',
'help' => 'Enable quiet output.',
'boolean' => true,
]);
}
} | Construct an OptionParser so you can define its behavior
@param string $command The command name this parser is for. The command name is used for generating help.
@param bool $defaultOptions Whether you want the verbose and quiet options set. Setting
this to false will prevent the addition of `--verbose` & `--quiet` options. | __construct | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function setCommand(string $text)
{
$this->_command = Inflector::underscore($text);
return $this;
} | Sets the command name for shell/task.
@param string $text The text to set.
@return $this | setCommand | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function setDescription(array|string $text)
{
if (is_array($text)) {
$text = implode("\n", $text);
}
$this->_description = $text;
return $this;
} | Sets the description text for shell/task.
@param array<string>|string $text The text to set. If an array the
text will be imploded with "\n".
@return $this | setDescription | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function setEpilog(array|string $text)
{
if (is_array($text)) {
$text = implode("\n", $text);
}
$this->_epilog = $text;
return $this;
} | Sets an epilog to the parser. The epilog is added to the end of
the options and arguments listing when help is generated.
@param array<string>|string $text The text to set. If an array the text will
be imploded with "\n".
@return $this | setEpilog | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function addOption(ConsoleInputOption|string $name, array $options = [])
{
if ($name instanceof ConsoleInputOption) {
$option = $name;
$name = $option->name();
} else {
$defaults = [
'short' => '',
'help' => '',
'default' => null,
'boolean' => false,
'multiple' => false,
'separator' => null,
'choices' => [],
'required' => false,
'prompt' => null,
];
$options += $defaults;
$option = new ConsoleInputOption(
$name,
$options['short'],
$options['help'],
$options['boolean'],
$options['default'],
$options['choices'],
$options['multiple'],
$options['required'],
$options['prompt'],
$options['separator'],
);
}
$this->_options[$name] = $option;
asort($this->_options);
if ($option->short()) {
if (isset($this->_shortOptions[$option->short()])) {
deprecationWarning('5.2.0', 'You cannot redefine short options. This will throw an error in 5.3.0+.');
}
$this->_shortOptions[$option->short()] = $name;
asort($this->_shortOptions);
}
return $this;
} | Add an option to the option parser. Options allow you to define optional or required
parameters for your console application. Options are defined by the parameters they use.
### Options
- `short` - The single letter variant for this option, leave undefined for none.
- `help` - Help text for this option. Used when generating help for the option.
- `default` - The default value for this option. Defaults are added into the parsed params when the
attached option is not provided or has no value. Using default and boolean together will not work.
are added into the parsed parameters when the option is undefined. Defaults to null.
- `boolean` - The option uses no value, it's just a boolean switch. Defaults to false.
If an option is defined as boolean, it will always be added to the parsed params. If no present
it will be false, if present it will be true.
- `multiple` - The option can be provided multiple times. The parsed option
will be an array of values when this option is enabled.
- `choices` A list of valid choices for this option. If left empty all values are valid..
An exception will be raised when parse() encounters an invalid value.
@param \Cake\Console\ConsoleInputOption|string $name The long name you want to the value to be parsed out
as when options are parsed. Will also accept an instance of ConsoleInputOption.
@param array<string, mixed> $options An array of parameters that define the behavior of the option
@return $this | addOption | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function removeOption(string $name)
{
unset($this->_options[$name]);
$key = array_search($name, $this->_shortOptions, true);
if ($key !== false) {
unset($this->_shortOptions[$key]);
}
return $this;
} | Remove an option from the option parser.
@param string $name The option name to remove.
@return $this | removeOption | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function addArgument(ConsoleInputArgument|string $name, array $params = [])
{
if ($name instanceof ConsoleInputArgument) {
$arg = $name;
$index = count($this->_args);
} else {
$defaults = [
'name' => $name,
'help' => '',
'index' => count($this->_args),
'required' => false,
'choices' => [],
'separator' => null,
];
$options = $params + $defaults;
$index = $options['index'];
unset($options['index']);
$arg = new ConsoleInputArgument($options);
}
foreach ($this->_args as $a) {
if ($a->isEqualTo($arg)) {
return $this;
}
if (!empty($options['required']) && !$a->isRequired()) {
throw new LogicException('A required argument cannot follow an optional one');
}
}
$this->_args[$index] = $arg;
ksort($this->_args);
return $this;
} | Add a positional argument to the option parser.
### Params
- `help` The help text to display for this argument.
- `required` Whether this parameter is required.
- `index` The index for the arg, if left undefined the argument will be put
onto the end of the arguments. If you define the same index twice the first
option will be overwritten.
- `choices` A list of valid choices for this argument. If left empty all values are valid..
An exception will be raised when parse() encounters an invalid value.
- `separator` A separator to allow writing argument in a list form.
@param \Cake\Console\ConsoleInputArgument|string $name The name of the argument.
Will also accept an instance of ConsoleInputArgument.
@param array<string, mixed> $params Parameters for the argument, see above.
@return $this | addArgument | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function setRootName(string $name)
{
$this->rootName = $name;
return $this;
} | Set the root name used in the HelpFormatter
@param string $name The root command name
@return $this | setRootName | php | cakephp/cakephp | src/Console/ConsoleOptionParser.php | https://github.com/cakephp/cakephp/blob/master/src/Console/ConsoleOptionParser.php | MIT |
public function __construct(ConsoleOptionParser $parser)
{
$this->_parser = $parser;
} | Build the help formatter for an OptionParser
@param \Cake\Console\ConsoleOptionParser $parser The option parser help is being generated for. | __construct | php | cakephp/cakephp | src/Console/HelpFormatter.php | https://github.com/cakephp/cakephp/blob/master/src/Console/HelpFormatter.php | MIT |
public function __construct()
{
parent::__construct();
fclose($this->_output);
unset($this->_output);
} | Constructor
Closes and unsets the file handle created in the parent constructor to
prevent 'too many open files' errors. | __construct | php | cakephp/cakephp | src/Console/TestSuite/StubConsoleOutput.php | https://github.com/cakephp/cakephp/blob/master/src/Console/TestSuite/StubConsoleOutput.php | MIT |
public function enableAutoRender()
{
$this->autoRender = true;
return $this;
} | Enable automatic action rendering.
@return $this
@since 3.6.0 | enableAutoRender | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function disableAutoRender()
{
$this->autoRender = false;
return $this;
} | Disable automatic action rendering.
@return $this
@since 3.6.0 | disableAutoRender | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function addViewClasses(array $viewClasses)
{
$this->viewClasses = array_merge($this->viewClasses, $viewClasses);
return $this;
} | Add View classes this controller can perform content negotiation with.
Each view class must implement the `getContentType()` hook method
to participate in negotiation.
@param array<string> $viewClasses View classes list.
@return $this
@see \Cake\Http\ContentTypeNegotiation
@since 4.5.0 | addViewClasses | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function beforeFilter(EventInterface $event)
{
} | Called before the controller action. You can use this method to configure and customize components
or perform logic that needs to happen before each controller action.
@param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event An Event instance
@return void
@link https://book.cakephp.org/5/en/controllers.html#request-life-cycle-callbacks
@phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint | beforeFilter | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function beforeRender(EventInterface $event)
{
} | Called after the controller action is run, but before the view is rendered. You can use this method
to perform logic or set view variables that are required on every request.
@param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event An Event instance
@return void
@link https://book.cakephp.org/5/en/controllers.html#request-life-cycle-callbacks
@phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint | beforeRender | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function beforeRedirect(EventInterface $event, UriInterface|array|string $url, Response $response)
{
} | The beforeRedirect method is invoked when the controller's redirect method is called but before any
further action.
If the event is stopped the controller will not continue on to redirect the request.
The $url and $status variables have same meaning as for the controller's method.
You can set the event result to response instance or modify the redirect location
using controller's response instance.
@param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event An Event instance
@param \Psr\Http\Message\UriInterface|array|string $url A string or array-based URL pointing to another location within the app,
or an absolute URL
@param \Cake\Http\Response $response The response object.
@return void
@link https://book.cakephp.org/5/en/controllers.html#request-life-cycle-callbacks
@phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint | beforeRedirect | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function afterFilter(EventInterface $event)
{
} | Called after the controller action is run and rendered.
@param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event An Event instance
@return void
@link https://book.cakephp.org/5/en/controllers.html#request-life-cycle-callbacks
@phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint | afterFilter | php | cakephp/cakephp | src/Controller/Controller.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Controller.php | MIT |
public function __construct(ComponentRegistry $registry, array $config = [])
{
$this->_registry = $registry;
$this->setConfig($config);
if ($this->components) {
$this->components = $registry->normalizeArray($this->components);
}
$this->initialize($config);
} | Constructor
@param \Cake\Controller\ComponentRegistry $registry A component registry
this component can use to lazy load its components.
@param array<string, mixed> $config Array of configuration settings. | __construct | php | cakephp/cakephp | src/Controller/Component.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Component.php | MIT |
public function setController(Controller $controller)
{
$this->_Controller = $controller;
$this->setEventManager($controller->getEventManager());
return $this;
} | Set the controller associated with the collection.
@param \Cake\Controller\Controller $controller Controller instance.
@return $this | setController | php | cakephp/cakephp | src/Controller/ComponentRegistry.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/ComponentRegistry.php | MIT |
public function setConfig(array|string $key, mixed $value = null, bool $merge = true)
{
$this->flash()->setConfig($key, $value, $merge);
return $this;
} | Proxy method to FlashMessage instance.
@param array<string, mixed>|string $key The key to set, or a complete array of configs.
@param mixed $value The value to set.
@param bool $merge Whether to recursively merge or overwrite existing config, defaults to true.
@return $this
@throws \Cake\Core\Exception\CakeException When trying to set a key that is invalid. | setConfig | php | cakephp/cakephp | src/Controller/Component/FlashComponent.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Component/FlashComponent.php | MIT |
public function configShallow(array|string $key, mixed $value = null)
{
$this->flash()->configShallow($key, $value);
return $this;
} | Proxy method to FlashMessage instance.
@param array<string, mixed>|string $key The key to set, or a complete array of configs.
@param mixed $value The value to set.
@return $this | configShallow | php | cakephp/cakephp | src/Controller/Component/FlashComponent.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Component/FlashComponent.php | MIT |
public function __construct(array|string $message = '', ?int $code = null, ?Throwable $previous = null)
{
if (is_array($message)) {
$this->_messageTemplate = $this->templates[$message['template']] ?? '';
unset($message['template']);
}
parent::__construct($message, $code, $previous);
} | Switches message template based on `template` key in message array.
@param array|string $message Either the string of the error message, or an array of attributes
that are made available in the view, and sprintf()'d into Exception::$_messageTemplate
@param int|null $code The error code
@param \Throwable|null $previous the previous exception. | __construct | php | cakephp/cakephp | src/Controller/Exception/InvalidParameterException.php | https://github.com/cakephp/cakephp/blob/master/src/Controller/Exception/InvalidParameterException.php | MIT |
public function __construct(string $name, array $config = [])
{
$this->_name = $name;
$allowed = [
'associations', 'instance', 'config', 'canBeJoined',
'aliasPath', 'propertyPath', 'forMatching', 'targetProperty',
];
foreach ($allowed as $property) {
if (isset($config[$property])) {
$this->{'_' . $property} = $config[$property];
}
}
} | Constructor. The $config parameter accepts the following array
keys:
- associations
- instance
- config
- canBeJoined
- aliasPath
- propertyPath
- forMatching
- targetProperty
The keys maps to the settable properties in this class.
@param string $name The Association name.
@param array<string, mixed> $config The list of properties to set. | __construct | php | cakephp/cakephp | src/ORM/EagerLoadable.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoadable.php | MIT |
public function setCanBeJoined(bool $possible)
{
$this->_canBeJoined = $possible;
return $this;
} | Sets whether this level can be fetched using a join.
@param bool $possible The value to set.
@return $this | setCanBeJoined | php | cakephp/cakephp | src/ORM/EagerLoadable.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoadable.php | MIT |
public function setConfig(array $config)
{
$this->_config = $config;
return $this;
} | Sets the list of options to pass to the association object for loading
the records.
@param array<string, mixed> $config The value to set.
@return $this | setConfig | php | cakephp/cakephp | src/ORM/EagerLoadable.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoadable.php | MIT |
public function __clone()
{
foreach ($this->_associations as $i => $association) {
$this->_associations[$i] = clone $association;
}
} | Handles cloning eager loadables.
@return void | __clone | php | cakephp/cakephp | src/ORM/EagerLoadable.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoadable.php | MIT |
public function __construct(Table $table, array $config = [])
{
$config = $this->_resolveMethodAliases(
'implementedFinders',
$this->_defaultConfig,
$config,
);
$config = $this->_resolveMethodAliases(
'implementedMethods',
$this->_defaultConfig,
$config,
);
$this->_table = $table;
$this->setConfig($config);
$this->initialize($config);
} | Constructor
Merges config with the default and store in the config property
@param \Cake\ORM\Table $table The table this behavior is attached to.
@param array<string, mixed> $config The config for this behavior. | __construct | php | cakephp/cakephp | src/ORM/Behavior.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Behavior.php | MIT |
public function __construct(?LocatorInterface $tableLocator = null)
{
if ($tableLocator !== null) {
$this->_tableLocator = $tableLocator;
}
} | Constructor.
Sets the default table locator for associations.
If no locator is provided, the global one will be used.
@param \Cake\ORM\Locator\LocatorInterface|null $tableLocator Table locator instance. | __construct | php | cakephp/cakephp | src/ORM/AssociationCollection.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/AssociationCollection.php | MIT |
public function enableAutoFields(bool $enable = true)
{
$this->_autoFields = $enable;
return $this;
} | Sets whether contained associations will load fields automatically.
@param bool $enable The value to set.
@return $this | enableAutoFields | php | cakephp/cakephp | src/ORM/EagerLoader.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoader.php | MIT |
public function disableAutoFields()
{
$this->_autoFields = false;
return $this;
} | Disable auto loading fields of contained associations.
@return $this | disableAutoFields | php | cakephp/cakephp | src/ORM/EagerLoader.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoader.php | MIT |
public function __clone()
{
if ($this->_matching) {
$this->_matching = clone $this->_matching;
}
} | Handles cloning eager loaders and eager loadables.
@return void | __clone | php | cakephp/cakephp | src/ORM/EagerLoader.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/EagerLoader.php | MIT |
public function setTable(string $table)
{
$this->_table = $table;
return $this;
} | Sets the database table name.
This can include the database schema name in the form 'schema.table'.
If the name must be quoted, enable automatic identifier quoting.
@param string $table Table name.
@return $this | setTable | php | cakephp/cakephp | src/ORM/Table.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php | MIT |
public function setRegistryAlias(string $registryAlias)
{
$this->_registryAlias = $registryAlias;
return $this;
} | Sets the table registry key used to create this table instance.
@param string $registryAlias The key used to access this object.
@return $this | setRegistryAlias | php | cakephp/cakephp | src/ORM/Table.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php | MIT |
public function setPrimaryKey(array|string $key)
{
$this->_primaryKey = $key;
return $this;
} | Sets the primary key field name.
@param array<string>|string $key Sets a new name to be used as primary key
@return $this | setPrimaryKey | php | cakephp/cakephp | src/ORM/Table.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php | MIT |
public function setEntityClass(string $name)
{
/** @var class-string<\Cake\Datasource\EntityInterface>|null $class */
$class = App::className($name, 'Model/Entity');
if ($class === null) {
throw new MissingEntityException([$name]);
}
$this->_entityClass = $class;
return $this;
} | Sets the class used to hydrate rows for this table.
@param string $name The name of the class to use
@throws \Cake\ORM\Exception\MissingEntityException when the entity class cannot be found
@return $this | setEntityClass | php | cakephp/cakephp | src/ORM/Table.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Table.php | MIT |
public function set(string $name, object $object)
{
parent::set($name, $object);
$methods = $this->_getMethods($object, $object::class, $name);
$this->_methodMap += $methods['methods'];
$this->_finderMap += $methods['finders'];
return $this;
} | Set an object directly into the registry by name.
@param string $name The name of the object to set in the registry.
@param \Cake\ORM\Behavior $object instance to store in the registry
@return $this | set | php | cakephp/cakephp | src/ORM/BehaviorRegistry.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/BehaviorRegistry.php | MIT |
public function __construct(array $properties = [], array $options = [])
{
$options += [
'useSetters' => true,
'markClean' => false,
'markNew' => null,
'guard' => false,
'source' => null,
];
if ($options['source'] !== null) {
$this->setSource($options['source']);
}
if ($options['markNew'] !== null) {
$this->setNew($options['markNew']);
}
if ($properties) {
//Remember the original field names here.
$this->setOriginalField(array_keys($properties));
if ($options['markClean'] && !$options['useSetters']) {
$this->_fields = $properties;
return;
}
$this->patch($properties, [
'asOriginal' => true,
'setter' => $options['useSetters'],
'guard' => $options['guard'],
]);
}
if ($options['markClean']) {
$this->clean();
}
} | Initializes the internal properties of this entity out of the
keys in an array. The following list of options can be used:
- useSetters: whether use internal setters for properties or not
- markClean: whether to mark all properties as clean after setting them
- markNew: whether this instance has not yet been persisted
- guard: whether to prevent inaccessible properties from being set (default: false)
- source: A string representing the alias of the repository this entity came from
### Example:
```
$entity = new Entity(['id' => 1, 'name' => 'Andrew'])
```
@param array<string, mixed> $properties hash of properties to set in this entity
@param array<string, mixed> $options list of options to use when creating this entity | __construct | php | cakephp/cakephp | src/ORM/Entity.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Entity.php | MIT |
public function __construct(string $alias, array $options = [])
{
$defaults = [
'cascadeCallbacks',
'className',
'conditions',
'dependent',
'finder',
'bindingKey',
'foreignKey',
'joinType',
'tableLocator',
'propertyName',
'sourceTable',
'targetTable',
];
foreach ($defaults as $property) {
if (isset($options[$property])) {
$this->{'_' . $property} = $options[$property];
}
}
$this->_className ??= $alias;
[, $name] = pluginSplit($alias);
$this->_name = $name;
$this->_options($options);
if (!empty($options['strategy'])) {
$this->setStrategy($options['strategy']);
}
} | Constructor. Subclasses can override _options function to get the original
list of passed options if expecting any other special key
@param string $alias The name given to the association
@param array<string, mixed> $options A list of properties to be set on this object | __construct | php | cakephp/cakephp | src/ORM/Association.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Association.php | MIT |
public function setCascadeCallbacks(bool $cascadeCallbacks)
{
$this->_cascadeCallbacks = $cascadeCallbacks;
return $this;
} | Sets whether cascaded deletes should also fire callbacks.
@param bool $cascadeCallbacks cascade callbacks switch value
@return $this | setCascadeCallbacks | php | cakephp/cakephp | src/ORM/Association.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Association.php | MIT |
public function setClassName(string $className)
{
if (
isset($this->_targetTable) &&
get_class($this->_targetTable) !== App::className($className, 'Model/Table', 'Table')
) {
throw new InvalidArgumentException(sprintf(
"The class name `%s` doesn't match the target table class name of `%s`.",
$className,
$this->_targetTable::class,
));
}
$this->_className = $className;
return $this;
} | Sets the class name of the target table object.
@param string $className Class name to set.
@return $this
@throws \InvalidArgumentException In case the class name is set after the target table has been
resolved, and it doesn't match the target table's class name. | setClassName | php | cakephp/cakephp | src/ORM/Association.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Association.php | MIT |
public function setSource(Table $table)
{
$this->_sourceTable = $table;
return $this;
} | Sets the table instance for the source side of the association.
@param \Cake\ORM\Table $table the instance to be assigned as source side
@return $this | setSource | php | cakephp/cakephp | src/ORM/Association.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Association.php | MIT |
public function setTarget(Table $table)
{
$this->_targetTable = $table;
return $this;
} | Sets the table instance for the target side of the association.
@param \Cake\ORM\Table $table the instance to be assigned as target side
@return $this | setTarget | php | cakephp/cakephp | src/ORM/Association.php | https://github.com/cakephp/cakephp/blob/master/src/ORM/Association.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.