Esempio n. 1
0
 /**
  * Set plugin manager for resolving filter classes
  *
  * @param  FilterPluginManager $manager
  * @return void
  */
 public static function setPluginManager(FilterPluginManager $manager = null)
 {
     // Don't share by default to allow different arguments on subsequent calls
     if ($manager instanceof FilterPluginManager) {
         $manager->setShareByDefault(false);
     }
     static::$plugins = $manager;
 }
 /**
  * Set plugin manager to use for locating validators
  *
  * @param  ValidatorPluginManager|null $plugins
  * @return void
  */
 public static function setPluginManager(ValidatorPluginManager $plugins = null)
 {
     // Don't share by default to allow different arguments on subsequent calls
     if ($plugins instanceof ValidatorPluginManager) {
         $plugins->setShareByDefault(false);
     }
     static::$plugins = $plugins;
 }
Esempio n. 3
0
 /**
  * Set plugin manager to use for locating validators
  *
  * @param  ValidatorPluginManager|null $plugins
  * @return void
  */
 public static function setPluginManager(ValidatorPluginManager $plugins = null)
 {
     // Don't share by default to allow different arguments on subsequent calls
     if ($plugins instanceof ValidatorPluginManager) {
         // Vary how the share by default flag is set based on zend-servicemanager version
         if (method_exists($plugins, 'configure')) {
             $plugins->configure(['shared_by_default' => false]);
         } else {
             $plugins->setShareByDefault(false);
         }
     }
     static::$plugins = $plugins;
 }
Esempio n. 4
0
 /**
  * Call hook on any registered plugins. 
  * Note: The hook name should be the first argument passed
  * 
  * Avoid calling this on parent classes
  */
 public function hook()
 {
     if (func_num_args() < 2) {
         return;
     }
     $args = func_get_args();
     $name = array_shift($args);
     if (!isset(static::$plugins)) {
         static::$plugins = new \SplObjectStorage();
         return;
     }
     foreach (static::$plugins as $plugin) {
         call_user_func_array(array($plugin, $name), $args);
     }
 }
Esempio n. 5
0
 /**
  * Resets the internal plugin manager
  *
  * @return void
  */
 public static function resetPluginManager()
 {
     static::$plugins = null;
 }
Esempio n. 6
0
 /**
  * Loads the published plugins.
  *
  * @return  array  An array of published plugins
  *
  * @since   3.2
  */
 protected static function load()
 {
     if (static::$plugins !== null) {
         return static::$plugins;
     }
     $user = JFactory::getUser();
     $cache = JFactory::getCache('com_plugins', '');
     $levels = implode(',', $user->getAuthorisedViewLevels());
     if (!(static::$plugins = $cache->get($levels))) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('folder AS type, element AS name, params')->from('#__extensions')->where('enabled >= 1')->where('type =' . $db->quote('plugin'))->where('state >= 0')->where('access IN (' . $levels . ')')->order('ordering');
         static::$plugins = $db->setQuery($query)->loadObjectList();
         $cache->store(static::$plugins, $levels);
     }
     return static::$plugins;
 }
Esempio n. 7
0
 /**
  * Returns plugin container.
  *
  * @return \Rain\Tpl\PluginContainer
  */
 protected static function getPlugins()
 {
     return static::$plugins ?: (static::$plugins = new PluginContainer());
 }
Esempio n. 8
0
 protected static function load($enabled = true)
 {
     if (static::$plugins !== null) {
         return static::$plugins;
     }
     $user = JFactory::getUser();
     $cache = JFactory::getCache('com_tz_portfolio_plus', '');
     $levels = implode(',', $user->getAuthorisedViewLevels());
     if (!(static::$plugins = $cache->get($levels))) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('id, folder AS type, element AS name, params, manifest_cache')->from('#__tz_portfolio_plus_extensions')->where('type =' . $db->quote('tz_portfolio_plus-plugin'))->order('ordering');
         if ($enabled) {
             $query->where('published = 1');
         }
         $db->setQuery($query);
         if ($plugins = $db->loadObjectList()) {
             foreach ($plugins as &$item) {
                 $item->manifest_cache = json_decode($item->manifest_cache);
             }
             static::$plugins = $plugins;
         } else {
             static::$plugins = false;
         }
         $cache->store(static::$plugins, $levels);
     }
     return static::$plugins;
 }
Esempio n. 9
0
 /**
  * Loads all available plugins for the site
  *
  * @return array
  */
 protected static function plugins()
 {
     // check for a cached plugins array
     if (!is_null(static::$plugins)) {
         return static::$plugins;
     }
     // check for an existing plugins dir
     if (!is_dir(c::$data['root.plugins'])) {
         return static::$plugins = array();
     }
     foreach (array_diff(scandir(c::$data['root.plugins']), array('.', '..')) as $file) {
         if (is_dir(c::$data['root.plugins'] . DS . $file)) {
             static::plugin($file, 'dir');
         } else {
             if (f::extension($file) == 'php') {
                 static::plugin(f::name($file), 'file');
             }
         }
     }
     return static::$plugins;
 }
Esempio n. 10
0
 /**
  * Clear cache of plugins
  * return void
  */
 public static function resetPluginsCache()
 {
     static::$plugins = array();
 }
Esempio n. 11
0
 /**
  * Loads the published plugins.
  *
  * @return  array  An array of published plugins
  *
  * @since   3.2
  */
 protected static function load()
 {
     if (static::$plugins !== null) {
         return static::$plugins;
     }
     $levels = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
     /** @var JCacheControllerCallback $cache */
     $cache = JFactory::getCache('com_plugins', 'callback');
     static::$plugins = $cache->get(function () use($levels) {
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select(array($db->quoteName('folder', 'type'), $db->quoteName('element', 'name'), $db->quoteName('params')))->from('#__extensions')->where('enabled = 1')->where('type = ' . $db->quote('plugin'))->where('state IN (0,1)')->where('access IN (' . $levels . ')')->order('ordering');
         $db->setQuery($query);
         return $db->loadObjectList();
     }, array(), md5($levels), false);
     return static::$plugins;
 }
Esempio n. 12
0
 /**
  * Set plugin manager for resolving filter classes
  *
  * @param  FilterPluginManager $manager
  * @return void
  */
 public static function setPluginManager(FilterPluginManager $manager = null)
 {
     static::$plugins = $manager;
 }