Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/flow-flo.../libs/cakephp/core
File: PluginCollection.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
[2] Fix | Delete
* Copyright 2005-2011, Cake Software Foundation, Inc. (https://cakefoundation.org)
[3] Fix | Delete
*
[4] Fix | Delete
* Licensed under The MIT License
[5] Fix | Delete
* Redistributions of files must retain the above copyright notice.
[6] Fix | Delete
*
[7] Fix | Delete
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
[8] Fix | Delete
* @link https://cakephp.org CakePHP(tm) Project
[9] Fix | Delete
* @since 3.6.0
[10] Fix | Delete
* @license https://opensource.org/licenses/mit-license.php MIT License
[11] Fix | Delete
*/
[12] Fix | Delete
namespace Cake\Core;
[13] Fix | Delete
[14] Fix | Delete
use Cake\Core\Exception\MissingPluginException;
[15] Fix | Delete
use Countable;
[16] Fix | Delete
use InvalidArgumentException;
[17] Fix | Delete
use Iterator;
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Plugin Collection
[21] Fix | Delete
*
[22] Fix | Delete
* Holds onto plugin objects loaded into an application, and
[23] Fix | Delete
* provides methods for iterating, and finding plugins based
[24] Fix | Delete
* on criteria.
[25] Fix | Delete
*
[26] Fix | Delete
* This class implements the Iterator interface to allow plugins
[27] Fix | Delete
* to be iterated, handling the situation where a plugin's hook
[28] Fix | Delete
* method (usually bootstrap) loads another plugin during iteration.
[29] Fix | Delete
*
[30] Fix | Delete
* While its implementation supported nested iteration it does not
[31] Fix | Delete
* support using `continue` or `break` inside loops.
[32] Fix | Delete
*/
[33] Fix | Delete
class PluginCollection implements Iterator, Countable
[34] Fix | Delete
{
[35] Fix | Delete
/**
[36] Fix | Delete
* Plugin list
[37] Fix | Delete
*
[38] Fix | Delete
* @var array
[39] Fix | Delete
*/
[40] Fix | Delete
protected $plugins = [];
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Names of plugins
[44] Fix | Delete
*
[45] Fix | Delete
* @var string[]
[46] Fix | Delete
*/
[47] Fix | Delete
protected $names = [];
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Iterator position stack.
[51] Fix | Delete
*
[52] Fix | Delete
* @var int[]
[53] Fix | Delete
*/
[54] Fix | Delete
protected $positions = [];
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Loop depth
[58] Fix | Delete
*
[59] Fix | Delete
* @var int
[60] Fix | Delete
*/
[61] Fix | Delete
protected $loopDepth = -1;
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Constructor
[65] Fix | Delete
*
[66] Fix | Delete
* @param array $plugins The map of plugins to add to the collection.
[67] Fix | Delete
*/
[68] Fix | Delete
public function __construct(array $plugins = [])
[69] Fix | Delete
{
[70] Fix | Delete
foreach ($plugins as $plugin) {
[71] Fix | Delete
$this->add($plugin);
[72] Fix | Delete
}
[73] Fix | Delete
$this->loadConfig();
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Load the path information stored in vendor/cakephp-plugins.php
[78] Fix | Delete
*
[79] Fix | Delete
* This file is generated by the cakephp/plugin-installer package and used
[80] Fix | Delete
* to locate plugins on the filesystem as applications can use `extra.plugin-paths`
[81] Fix | Delete
* in their composer.json file to move plugin outside of vendor/
[82] Fix | Delete
*
[83] Fix | Delete
* @internal
[84] Fix | Delete
* @return void
[85] Fix | Delete
*/
[86] Fix | Delete
protected function loadConfig()
[87] Fix | Delete
{
[88] Fix | Delete
if (Configure::check('plugins')) {
[89] Fix | Delete
return;
[90] Fix | Delete
}
[91] Fix | Delete
$vendorFile = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'cakephp-plugins.php';
[92] Fix | Delete
if (!file_exists($vendorFile)) {
[93] Fix | Delete
$vendorFile = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'cakephp-plugins.php';
[94] Fix | Delete
if (!file_exists($vendorFile)) {
[95] Fix | Delete
Configure::write(['plugins' => []]);
[96] Fix | Delete
[97] Fix | Delete
return;
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
$config = require $vendorFile;
[102] Fix | Delete
Configure::write($config);
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
/**
[106] Fix | Delete
* Locate a plugin path by looking at configuration data.
[107] Fix | Delete
*
[108] Fix | Delete
* This will use the `plugins` Configure key, and fallback to enumerating `App::path('Plugin')`
[109] Fix | Delete
*
[110] Fix | Delete
* This method is not part of the official public API as plugins with
[111] Fix | Delete
* no plugin class are being phased out.
[112] Fix | Delete
*
[113] Fix | Delete
* @param string $name The plugin name to locate a path for. Will return '' when a plugin cannot be found.
[114] Fix | Delete
* @return string
[115] Fix | Delete
* @throws \Cake\Core\Exception\MissingPluginException when a plugin path cannot be resolved.
[116] Fix | Delete
* @internal
[117] Fix | Delete
*/
[118] Fix | Delete
public function findPath($name)
[119] Fix | Delete
{
[120] Fix | Delete
$this->loadConfig();
[121] Fix | Delete
[122] Fix | Delete
$path = Configure::read('plugins.' . $name);
[123] Fix | Delete
if ($path) {
[124] Fix | Delete
return $path;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$pluginPath = str_replace('/', DIRECTORY_SEPARATOR, $name);
[128] Fix | Delete
$paths = App::path('Plugin');
[129] Fix | Delete
foreach ($paths as $path) {
[130] Fix | Delete
if (is_dir($path . $pluginPath)) {
[131] Fix | Delete
return $path . $pluginPath . DIRECTORY_SEPARATOR;
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
throw new MissingPluginException(['plugin' => $name]);
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Add a plugin to the collection
[140] Fix | Delete
*
[141] Fix | Delete
* Plugins will be keyed by their names.
[142] Fix | Delete
*
[143] Fix | Delete
* @param \Cake\Core\PluginInterface $plugin The plugin to load.
[144] Fix | Delete
* @return $this
[145] Fix | Delete
*/
[146] Fix | Delete
public function add(PluginInterface $plugin)
[147] Fix | Delete
{
[148] Fix | Delete
$name = $plugin->getName();
[149] Fix | Delete
$this->plugins[$name] = $plugin;
[150] Fix | Delete
$this->names = array_keys($this->plugins);
[151] Fix | Delete
[152] Fix | Delete
return $this;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
/**
[156] Fix | Delete
* Remove a plugin from the collection if it exists.
[157] Fix | Delete
*
[158] Fix | Delete
* @param string $name The named plugin.
[159] Fix | Delete
* @return $this
[160] Fix | Delete
*/
[161] Fix | Delete
public function remove($name)
[162] Fix | Delete
{
[163] Fix | Delete
unset($this->plugins[$name]);
[164] Fix | Delete
$this->names = array_keys($this->plugins);
[165] Fix | Delete
[166] Fix | Delete
return $this;
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Remove all plugins from the collection
[171] Fix | Delete
*
[172] Fix | Delete
* @return $this
[173] Fix | Delete
*/
[174] Fix | Delete
public function clear()
[175] Fix | Delete
{
[176] Fix | Delete
$this->plugins = [];
[177] Fix | Delete
$this->names = [];
[178] Fix | Delete
$this->positions = [];
[179] Fix | Delete
$this->loopDepth = -1;
[180] Fix | Delete
[181] Fix | Delete
return $this;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
/**
[185] Fix | Delete
* Check whether the named plugin exists in the collection.
[186] Fix | Delete
*
[187] Fix | Delete
* @param string $name The named plugin.
[188] Fix | Delete
* @return bool
[189] Fix | Delete
*/
[190] Fix | Delete
public function has($name)
[191] Fix | Delete
{
[192] Fix | Delete
return isset($this->plugins[$name]);
[193] Fix | Delete
}
[194] Fix | Delete
[195] Fix | Delete
/**
[196] Fix | Delete
* Get the a plugin by name
[197] Fix | Delete
*
[198] Fix | Delete
* @param string $name The plugin to get.
[199] Fix | Delete
* @return \Cake\Core\PluginInterface The plugin.
[200] Fix | Delete
* @throws \Cake\Core\Exception\MissingPluginException when unknown plugins are fetched.
[201] Fix | Delete
*/
[202] Fix | Delete
public function get($name)
[203] Fix | Delete
{
[204] Fix | Delete
if (!$this->has($name)) {
[205] Fix | Delete
throw new MissingPluginException(['plugin' => $name]);
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
return $this->plugins[$name];
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Implementation of Countable.
[213] Fix | Delete
*
[214] Fix | Delete
* Get the number of plugins in the collection.
[215] Fix | Delete
*
[216] Fix | Delete
* @return int
[217] Fix | Delete
*/
[218] Fix | Delete
public function count()
[219] Fix | Delete
{
[220] Fix | Delete
return count($this->plugins);
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
/**
[224] Fix | Delete
* Part of Iterator Interface
[225] Fix | Delete
*
[226] Fix | Delete
* @return void
[227] Fix | Delete
*/
[228] Fix | Delete
public function next()
[229] Fix | Delete
{
[230] Fix | Delete
$this->positions[$this->loopDepth]++;
[231] Fix | Delete
}
[232] Fix | Delete
[233] Fix | Delete
/**
[234] Fix | Delete
* Part of Iterator Interface
[235] Fix | Delete
*
[236] Fix | Delete
* @return string
[237] Fix | Delete
*/
[238] Fix | Delete
public function key()
[239] Fix | Delete
{
[240] Fix | Delete
return $this->names[$this->positions[$this->loopDepth]];
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
/**
[244] Fix | Delete
* Part of Iterator Interface
[245] Fix | Delete
*
[246] Fix | Delete
* @return \Cake\Core\PluginInterface
[247] Fix | Delete
*/
[248] Fix | Delete
public function current()
[249] Fix | Delete
{
[250] Fix | Delete
$position = $this->positions[$this->loopDepth];
[251] Fix | Delete
$name = $this->names[$position];
[252] Fix | Delete
[253] Fix | Delete
return $this->plugins[$name];
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Part of Iterator Interface
[258] Fix | Delete
*
[259] Fix | Delete
* @return void
[260] Fix | Delete
*/
[261] Fix | Delete
public function rewind()
[262] Fix | Delete
{
[263] Fix | Delete
$this->positions[] = 0;
[264] Fix | Delete
$this->loopDepth += 1;
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Part of Iterator Interface
[269] Fix | Delete
*
[270] Fix | Delete
* @return bool
[271] Fix | Delete
*/
[272] Fix | Delete
public function valid()
[273] Fix | Delete
{
[274] Fix | Delete
$valid = isset($this->names[$this->positions[$this->loopDepth]]);
[275] Fix | Delete
if (!$valid) {
[276] Fix | Delete
array_pop($this->positions);
[277] Fix | Delete
$this->loopDepth -= 1;
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
return $valid;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Filter the plugins to those with the named hook enabled.
[285] Fix | Delete
*
[286] Fix | Delete
* @param string $hook The hook to filter plugins by
[287] Fix | Delete
* @return \Generator A generator containing matching plugins.
[288] Fix | Delete
* @throws \InvalidArgumentException on invalid hooks
[289] Fix | Delete
*/
[290] Fix | Delete
public function with($hook)
[291] Fix | Delete
{
[292] Fix | Delete
if (!in_array($hook, PluginInterface::VALID_HOOKS)) {
[293] Fix | Delete
throw new InvalidArgumentException("The `{$hook}` hook is not a known plugin hook.");
[294] Fix | Delete
}
[295] Fix | Delete
foreach ($this as $plugin) {
[296] Fix | Delete
if ($plugin->isEnabled($hook)) {
[297] Fix | Delete
yield $plugin;
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
}
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function