BootstrapAbstract.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Application
  17. * @subpackage Bootstrap
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Application_Bootstrap_Bootstrapper
  24. */
  25. require_once 'Zend/Application/Bootstrap/Bootstrapper.php';
  26. /**
  27. * @see Zend_Application_Bootstrap_ResourceBootstrapper
  28. */
  29. require_once 'Zend/Application/Bootstrap/ResourceBootstrapper.php';
  30. /**
  31. * Abstract base class for bootstrap classes
  32. *
  33. * @uses Zend_Application_Bootstrap_Bootstrapper
  34. * @uses Zend_Application_Bootstrap_ResourceBootstrapper
  35. * @category Zend
  36. * @package Zend_Application
  37. * @subpackage Bootstrap
  38. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. */
  41. abstract class Zend_Application_Bootstrap_BootstrapAbstract
  42. implements Zend_Application_Bootstrap_Bootstrapper,
  43. Zend_Application_Bootstrap_ResourceBootstrapper
  44. {
  45. /**
  46. * @var Zend_Application|Zend_Application_Bootstrap_Bootstrapper
  47. */
  48. protected $_application;
  49. /**
  50. * @var array Internal resource methods (resource/method pairs)
  51. */
  52. protected $_classResources;
  53. /**
  54. * @var object Resource container
  55. */
  56. protected $_container;
  57. /**
  58. * @var string
  59. */
  60. protected $_environment;
  61. /**
  62. * Flattened (lowercase) option keys used for lookups
  63. *
  64. * @var array
  65. */
  66. protected $_optionKeys = array();
  67. /**
  68. * @var array
  69. */
  70. protected $_options = array();
  71. /**
  72. * @var Zend_Loader_PluginLoader_Interface
  73. */
  74. protected $_pluginLoader;
  75. /**
  76. * @var array Class-based resource plugins
  77. */
  78. protected $_pluginResources = array();
  79. /**
  80. * @var array Initializers that have been run
  81. */
  82. protected $_run = array();
  83. /**
  84. * @var array Initializers that have been started but not yet completed (circular dependency detection)
  85. */
  86. protected $_started = array();
  87. /**
  88. * Constructor
  89. *
  90. * Sets application object, initializes options, and prepares list of
  91. * initializer methods.
  92. *
  93. * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  94. * @return void
  95. * @throws Zend_Application_Bootstrap_Exception When invalid application is provided
  96. */
  97. public function __construct($application)
  98. {
  99. $this->setApplication($application);
  100. $options = $application->getOptions();
  101. $this->setOptions($options);
  102. }
  103. /**
  104. * Set class state
  105. *
  106. * @param array $options
  107. * @return Zend_Application_Bootstrap_BootstrapAbstract
  108. */
  109. public function setOptions(array $options)
  110. {
  111. $this->_options = $this->mergeOptions($this->_options, $options);
  112. $options = array_change_key_case($options, CASE_LOWER);
  113. $this->_optionKeys = array_merge($this->_optionKeys, array_keys($options));
  114. $methods = get_class_methods($this);
  115. foreach ($methods as $key => $method) {
  116. $methods[$key] = strtolower($method);
  117. }
  118. if (array_key_exists('pluginpaths', $options)) {
  119. $pluginLoader = $this->getPluginLoader();
  120. foreach ($options['pluginpaths'] as $prefix => $path) {
  121. $pluginLoader->addPrefixPath($prefix, $path);
  122. }
  123. unset($options['pluginpaths']);
  124. }
  125. foreach ($options as $key => $value) {
  126. $method = 'set' . strtolower($key);
  127. if (in_array($method, $methods)) {
  128. $this->$method($value);
  129. } elseif ('resources' == $key) {
  130. foreach ($value as $resource => $resourceOptions) {
  131. $this->registerPluginResource($resource, $resourceOptions);
  132. }
  133. }
  134. }
  135. return $this;
  136. }
  137. /**
  138. * Get current options from bootstrap
  139. *
  140. * @return array
  141. */
  142. public function getOptions()
  143. {
  144. return $this->_options;
  145. }
  146. /**
  147. * Is an option present?
  148. *
  149. * @param string $key
  150. * @return bool
  151. */
  152. public function hasOption($key)
  153. {
  154. return in_array(strtolower($key), $this->_optionKeys);
  155. }
  156. /**
  157. * Retrieve a single option
  158. *
  159. * @param string $key
  160. * @return mixed
  161. */
  162. public function getOption($key)
  163. {
  164. if ($this->hasOption($key)) {
  165. $options = $this->getOptions();
  166. $options = array_change_key_case($options, CASE_LOWER);
  167. return $options[strtolower($key)];
  168. }
  169. return null;
  170. }
  171. /**
  172. * Merge options recursively
  173. *
  174. * @param array $array1
  175. * @param mixed $array2
  176. * @return array
  177. */
  178. public function mergeOptions(array $array1, $array2 = null)
  179. {
  180. if (is_array($array2)) {
  181. foreach ($array2 as $key => $val) {
  182. if (is_array($array2[$key])) {
  183. $array1[$key] = (array_key_exists($key, $array1) && is_array($array1[$key]))
  184. ? $this->mergeOptions($array1[$key], $array2[$key])
  185. : $array2[$key];
  186. } else {
  187. $array1[$key] = $val;
  188. }
  189. }
  190. }
  191. return $array1;
  192. }
  193. /**
  194. * Get class resources (as resource/method pairs)
  195. *
  196. * Uses get_class_methods() by default, reflection on prior to 5.2.6,
  197. * as a bug prevents the usage of get_class_methods() there.
  198. *
  199. * @return array
  200. */
  201. public function getClassResources()
  202. {
  203. if (null === $this->_classResources) {
  204. if (version_compare(PHP_VERSION, '5.2.6') === -1) {
  205. $class = new ReflectionObject($this);
  206. $classMethods = $class->getMethods();
  207. $methodNames = array();
  208. foreach ($classMethods as $method) {
  209. $methodNames[] = $method->getName();
  210. }
  211. } else {
  212. $methodNames = get_class_methods($this);
  213. }
  214. $this->_classResources = array();
  215. foreach ($methodNames as $method) {
  216. if (5 < strlen($method) && '_init' === substr($method, 0, 5)) {
  217. $this->_classResources[strtolower(substr($method, 5))] = $method;
  218. }
  219. }
  220. }
  221. return $this->_classResources;
  222. }
  223. /**
  224. * Get class resource names
  225. *
  226. * @return array
  227. */
  228. public function getClassResourceNames()
  229. {
  230. $resources = $this->getClassResources();
  231. return array_keys($resources);
  232. }
  233. /**
  234. * Register a new resource plugin
  235. *
  236. * @param string|Zend_Application_Resource_Resource $resource
  237. * @param mixed $options
  238. * @return Zend_Application_Bootstrap_BootstrapAbstract
  239. * @throws Zend_Application_Bootstrap_Exception When invalid resource is provided
  240. */
  241. public function registerPluginResource($resource, $options = null)
  242. {
  243. if ($resource instanceof Zend_Application_Resource_Resource) {
  244. $resource->setBootstrap($this);
  245. $pluginName = $this->_resolvePluginResourceName($resource);
  246. $this->_pluginResources[$pluginName] = $resource;
  247. return $this;
  248. }
  249. if (!is_string($resource)) {
  250. throw new Zend_Application_Bootstrap_Exception('Invalid resource provided to ' . __METHOD__);
  251. }
  252. $this->_pluginResources[$resource] = $options;
  253. return $this;
  254. }
  255. /**
  256. * Unregister a resource from the bootstrap
  257. *
  258. * @param string|Zend_Application_Resource_Resource $resource
  259. * @return Zend_Application_Bootstrap_BootstrapAbstract
  260. * @throws Zend_Application_Bootstrap_Exception When unknown resource type is provided
  261. */
  262. public function unregisterPluginResource($resource)
  263. {
  264. if ($resource instanceof Zend_Application_Resource_Resource) {
  265. if ($index = array_search($resource, $this->_pluginResources, true)) {
  266. unset($this->_pluginResources[$index]);
  267. }
  268. return $this;
  269. }
  270. if (!is_string($resource)) {
  271. throw new Zend_Application_Bootstrap_Exception('Unknown resource type provided to ' . __METHOD__);
  272. }
  273. $resource = strtolower($resource);
  274. if (array_key_exists($resource, $this->_pluginResources)) {
  275. unset($this->_pluginResources[$resource]);
  276. }
  277. return $this;
  278. }
  279. /**
  280. * Is the requested plugin resource registered?
  281. *
  282. * @param string $resource
  283. * @return bool
  284. */
  285. public function hasPluginResource($resource)
  286. {
  287. return (null !== $this->getPluginResource($resource));
  288. }
  289. /**
  290. * Get a registered plugin resource
  291. *
  292. * @param string $resourceName
  293. * @return Zend_Application_Resource_Resource
  294. */
  295. public function getPluginResource($resource)
  296. {
  297. if (array_key_exists(strtolower($resource), $this->_pluginResources)) {
  298. $resource = strtolower($resource);
  299. if (!$this->_pluginResources[$resource] instanceof Zend_Application_Resource_Resource) {
  300. $resourceName = $this->_loadPluginResource($resource, $this->_pluginResources[$resource]);
  301. if (!$resourceName) {
  302. throw new Zend_Application_Bootstrap_Exception(sprintf('Unable to resolve plugin "%s"; no corresponding plugin with that name', $resource));
  303. }
  304. $resource = $resourceName;
  305. }
  306. return $this->_pluginResources[$resource];
  307. }
  308. foreach ($this->_pluginResources as $plugin => $spec) {
  309. if ($spec instanceof Zend_Application_Resource_Resource) {
  310. $pluginName = $this->_resolvePluginResourceName($spec);
  311. if (0 === strcasecmp($resource, $pluginName)) {
  312. unset($this->_pluginResources[$plugin]);
  313. $this->_pluginResources[$pluginName] = $spec;
  314. return $spec;
  315. }
  316. continue;
  317. }
  318. if (false !== $pluginName = $this->_loadPluginResource($plugin, $spec)) {
  319. if (0 === strcasecmp($resource, $pluginName)) {
  320. return $this->_pluginResources[$pluginName];
  321. }
  322. continue;
  323. }
  324. if (class_exists($plugin)
  325. && is_subclass_of($plugin, 'Zend_Application_Resource_Resource')
  326. ) { //@SEE ZF-7550
  327. $spec = (array) $spec;
  328. $spec['bootstrap'] = $this;
  329. $instance = new $plugin($spec);
  330. $pluginName = $this->_resolvePluginResourceName($instance);
  331. unset($this->_pluginResources[$plugin]);
  332. $this->_pluginResources[$pluginName] = $instance;
  333. if (0 === strcasecmp($resource, $pluginName)) {
  334. return $instance;
  335. }
  336. }
  337. }
  338. return null;
  339. }
  340. /**
  341. * Retrieve all plugin resources
  342. *
  343. * @return array
  344. */
  345. public function getPluginResources()
  346. {
  347. foreach (array_keys($this->_pluginResources) as $resource) {
  348. $this->getPluginResource($resource);
  349. }
  350. return $this->_pluginResources;
  351. }
  352. /**
  353. * Retrieve plugin resource names
  354. *
  355. * @return array
  356. */
  357. public function getPluginResourceNames()
  358. {
  359. $this->getPluginResources();
  360. return array_keys($this->_pluginResources);
  361. }
  362. /**
  363. * Set plugin loader for loading resources
  364. *
  365. * @param Zend_Loader_PluginLoader_Interface $loader
  366. * @return Zend_Application_Bootstrap_BootstrapAbstract
  367. */
  368. public function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
  369. {
  370. $this->_pluginLoader = $loader;
  371. return $this;
  372. }
  373. /**
  374. * Get the plugin loader for resources
  375. *
  376. * @return Zend_Loader_PluginLoader_Interface
  377. */
  378. public function getPluginLoader()
  379. {
  380. if ($this->_pluginLoader === null) {
  381. $options = array(
  382. 'Zend_Application_Resource' => 'Zend/Application/Resource',
  383. 'ZendX_Application_Resource' => 'ZendX/Application/Resource'
  384. );
  385. $this->_pluginLoader = new Zend_Loader_PluginLoader($options);
  386. }
  387. return $this->_pluginLoader;
  388. }
  389. /**
  390. * Set application/parent bootstrap
  391. *
  392. * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application
  393. * @return Zend_Application_Bootstrap_BootstrapAbstract
  394. */
  395. public function setApplication($application)
  396. {
  397. if (($application instanceof Zend_Application)
  398. || ($application instanceof Zend_Application_Bootstrap_Bootstrapper)
  399. ) {
  400. if ($application === $this) {
  401. throw new Zend_Application_Bootstrap_Exception('Cannot set application to same object; creates recursion');
  402. }
  403. $this->_application = $application;
  404. } else {
  405. throw new Zend_Application_Bootstrap_Exception('Invalid application provided to bootstrap constructor (received "' . get_class($application) . '" instance)');
  406. }
  407. return $this;
  408. }
  409. /**
  410. * Retrieve parent application instance
  411. *
  412. * @return Zend_Application|Zend_Application_Bootstrap_Bootstrapper
  413. */
  414. public function getApplication()
  415. {
  416. return $this->_application;
  417. }
  418. /**
  419. * Retrieve application environment
  420. *
  421. * @return string
  422. */
  423. public function getEnvironment()
  424. {
  425. if (null === $this->_environment) {
  426. $this->_environment = $this->getApplication()->getEnvironment();
  427. }
  428. return $this->_environment;
  429. }
  430. /**
  431. * Set resource container
  432. *
  433. * By default, if a resource callback has a non-null return value, this
  434. * value will be stored in a container using the resource name as the
  435. * key.
  436. *
  437. * Containers must be objects, and must allow setting public properties.
  438. *
  439. * @param object $container
  440. * @return Zend_Application_Bootstrap_BootstrapAbstract
  441. */
  442. public function setContainer($container)
  443. {
  444. if (!is_object($container)) {
  445. throw new Zend_Application_Bootstrap_Exception('Resource containers must be objects');
  446. }
  447. $this->_container = $container;
  448. return $this;
  449. }
  450. /**
  451. * Retrieve resource container
  452. *
  453. * @return object
  454. */
  455. public function getContainer()
  456. {
  457. if (null === $this->_container) {
  458. $this->setContainer(new Zend_Registry());
  459. }
  460. return $this->_container;
  461. }
  462. /**
  463. * Determine if a resource has been stored in the container
  464. *
  465. * During bootstrap resource initialization, you may return a value. If
  466. * you do, it will be stored in the {@link setContainer() container}.
  467. * You can use this method to determine if a value was stored.
  468. *
  469. * @param string $name
  470. * @return bool
  471. */
  472. public function hasResource($name)
  473. {
  474. $resource = strtolower($name);
  475. $container = $this->getContainer();
  476. return isset($container->{$resource});
  477. }
  478. /**
  479. * Retrieve a resource from the container
  480. *
  481. * During bootstrap resource initialization, you may return a value. If
  482. * you do, it will be stored in the {@link setContainer() container}.
  483. * You can use this method to retrieve that value.
  484. *
  485. * If no value was returned, this will return a null value.
  486. *
  487. * @param string $name
  488. * @return null|mixed
  489. */
  490. public function getResource($name)
  491. {
  492. $resource = strtolower($name);
  493. $container = $this->getContainer();
  494. if ($this->hasResource($resource)) {
  495. return $container->{$resource};
  496. }
  497. return null;
  498. }
  499. /**
  500. * Implement PHP's magic to retrieve a ressource
  501. * in the bootstrap
  502. *
  503. * @param string $prop
  504. * @return null|mixed
  505. */
  506. public function __get($prop)
  507. {
  508. return $this->getResource($prop);
  509. }
  510. /**
  511. * Implement PHP's magic to ask for the
  512. * existence of a ressource in the bootstrap
  513. *
  514. * @param string $prop
  515. * @return bool
  516. */
  517. public function __isset($prop)
  518. {
  519. return $this->hasResource($prop);
  520. }
  521. /**
  522. * Bootstrap individual, all, or multiple resources
  523. *
  524. * Marked as final to prevent issues when subclassing and naming the
  525. * child class 'Bootstrap' (in which case, overriding this method
  526. * would result in it being treated as a constructor).
  527. *
  528. * If you need to override this functionality, override the
  529. * {@link _bootstrap()} method.
  530. *
  531. * @param null|string|array $resource
  532. * @return Zend_Application_Bootstrap_BootstrapAbstract
  533. * @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
  534. */
  535. final public function bootstrap($resource = null)
  536. {
  537. $this->_bootstrap($resource);
  538. return $this;
  539. }
  540. /**
  541. * Overloading: intercept calls to bootstrap<resourcename>() methods
  542. *
  543. * @param string $method
  544. * @param array $args
  545. * @return void
  546. * @throws Zend_Application_Bootstrap_Exception On invalid method name
  547. */
  548. public function __call($method, $args)
  549. {
  550. if (9 < strlen($method) && 'bootstrap' === substr($method, 0, 9)) {
  551. $resource = substr($method, 9);
  552. return $this->bootstrap($resource);
  553. }
  554. throw new Zend_Application_Bootstrap_Exception('Invalid method "' . $method . '"');
  555. }
  556. /**
  557. * Bootstrap implementation
  558. *
  559. * This method may be overridden to provide custom bootstrapping logic.
  560. * It is the sole method called by {@link bootstrap()}.
  561. *
  562. * @param null|string|array $resource
  563. * @return void
  564. * @throws Zend_Application_Bootstrap_Exception When invalid argument was passed
  565. */
  566. protected function _bootstrap($resource = null)
  567. {
  568. if (null === $resource) {
  569. foreach ($this->getClassResourceNames() as $resource) {
  570. $this->_executeResource($resource);
  571. }
  572. foreach ($this->getPluginResourceNames() as $resource) {
  573. $this->_executeResource($resource);
  574. }
  575. } elseif (is_string($resource)) {
  576. $this->_executeResource($resource);
  577. } elseif (is_array($resource)) {
  578. foreach ($resource as $r) {
  579. $this->_executeResource($r);
  580. }
  581. } else {
  582. throw new Zend_Application_Bootstrap_Exception('Invalid argument passed to ' . __METHOD__);
  583. }
  584. }
  585. /**
  586. * Execute a resource
  587. *
  588. * Checks to see if the resource has already been run. If not, it searches
  589. * first to see if a local method matches the resource, and executes that.
  590. * If not, it checks to see if a plugin resource matches, and executes that
  591. * if found.
  592. *
  593. * Finally, if not found, it throws an exception.
  594. *
  595. * @param string $resource
  596. * @return void
  597. * @throws Zend_Application_Bootstrap_Exception When resource not found
  598. */
  599. protected function _executeResource($resource)
  600. {
  601. $resourceName = strtolower($resource);
  602. if (in_array($resourceName, $this->_run)) {
  603. return;
  604. }
  605. if (isset($this->_started[$resourceName]) && $this->_started[$resourceName]) {
  606. throw new Zend_Application_Bootstrap_Exception('Circular resource dependency detected');
  607. }
  608. $classResources = $this->getClassResources();
  609. if (array_key_exists($resourceName, $classResources)) {
  610. $this->_started[$resourceName] = true;
  611. $method = $classResources[$resourceName];
  612. $return = $this->$method();
  613. unset($this->_started[$resourceName]);
  614. $this->_markRun($resourceName);
  615. if (null !== $return) {
  616. $this->getContainer()->{$resourceName} = $return;
  617. }
  618. return;
  619. }
  620. if ($this->hasPluginResource($resource)) {
  621. $this->_started[$resourceName] = true;
  622. $plugin = $this->getPluginResource($resource);
  623. $return = $plugin->init();
  624. unset($this->_started[$resourceName]);
  625. $this->_markRun($resourceName);
  626. if (null !== $return) {
  627. $this->getContainer()->{$resourceName} = $return;
  628. }
  629. return;
  630. }
  631. throw new Zend_Application_Bootstrap_Exception('Resource matching "' . $resource . '" not found');
  632. }
  633. /**
  634. * Load a plugin resource
  635. *
  636. * @param string $resource
  637. * @param array|object|null $options
  638. * @return string|false
  639. */
  640. protected function _loadPluginResource($resource, $options)
  641. {
  642. $options = (array) $options;
  643. $options['bootstrap'] = $this;
  644. $className = $this->getPluginLoader()->load(strtolower($resource), false);
  645. if (!$className) {
  646. return false;
  647. }
  648. $instance = new $className($options);
  649. unset($this->_pluginResources[$resource]);
  650. if (isset($instance->_explicitType)) {
  651. $resource = $instance->_explicitType;
  652. }
  653. $resource = strtolower($resource);
  654. $this->_pluginResources[$resource] = $instance;
  655. return $resource;
  656. }
  657. /**
  658. * Mark a resource as having run
  659. *
  660. * @param string $resource
  661. * @return void
  662. */
  663. protected function _markRun($resource)
  664. {
  665. if (!in_array($resource, $this->_run)) {
  666. $this->_run[] = $resource;
  667. }
  668. }
  669. /**
  670. * Resolve a plugin resource name
  671. *
  672. * Uses, in order of preference
  673. * - $_explicitType property of resource
  674. * - Short name of resource (if a matching prefix path is found)
  675. * - class name (if none of the above are true)
  676. *
  677. * The name is then cast to lowercase.
  678. *
  679. * @param Zend_Application_Resource_Resource $resource
  680. * @return string
  681. */
  682. protected function _resolvePluginResourceName($resource)
  683. {
  684. if (isset($resource->_explicitType)) {
  685. $pluginName = $resource->_explicitType;
  686. } else {
  687. $className = get_class($resource);
  688. $pluginName = $className;
  689. $loader = $this->getPluginLoader();
  690. foreach ($loader->getPaths() as $prefix => $paths) {
  691. if (0 === strpos($className, $prefix)) {
  692. $pluginName = substr($className, strlen($prefix));
  693. $pluginName = trim($pluginName, '_');
  694. break;
  695. }
  696. }
  697. }
  698. $pluginName = strtolower($pluginName);
  699. return $pluginName;
  700. }
  701. }