当前位置: 首页>>代码示例>>PHP>>正文


PHP pluginSplit函数代码示例

本文整理汇总了PHP中pluginSplit函数的典型用法代码示例。如果您正苦于以下问题:PHP pluginSplit函数的具体用法?PHP pluginSplit怎么用?PHP pluginSplit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pluginSplit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startup

 /**
  * Override startup of the Shell
  *
  * @return void
  */
 public function startup()
 {
     parent::startup();
     if (isset($this->params['connection'])) {
         $this->connection = $this->params['connection'];
     }
     $class = Configure::read('Acl.classname');
     list($plugin, $class) = pluginSplit($class, true);
     App::uses($class, $plugin . 'Controller/Component/Acl');
     if (!in_array($class, array('DbAcl', 'DB_ACL')) && !is_subclass_of($class, 'DbAcl')) {
         $out = "--------------------------------------------------\n";
         $out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
         $out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
         $out .= "--------------------------------------------------\n";
         $out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
         $out .= "--------------------------------------------------\n";
         $this->err($out);
         $this->_stop();
     }
     if ($this->command) {
         if (!config('database')) {
             $this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
             $this->args = null;
             return $this->DbConfig->execute();
         }
         require_once APP . 'Config' . DS . 'database.php';
         if (!in_array($this->command, array('initdb'))) {
             $collection = new ComponentCollection();
             $this->Acl = new AclComponent($collection);
             $controller = new Controller();
             $this->Acl->startup($controller);
         }
     }
 }
开发者ID:rednazj,项目名称:Inventory,代码行数:39,代码来源:AclShell.php

示例2: authenticate

 /**
  * Authenticates the identity contained in a request.  Will use the `settings.userModel`, and `settings.fields`
  * to find POST data that is used to find a matching record in the `settings.userModel`.  Will return false if
  * there is no post data, either username or password is missing, of if the scope conditions have not been met.
  *
  * @param CakeRequest $request The request that contains login information.
  * @param CakeResponse $response Unused response object.
  * @return mixed.  False on login failure.  An array of User data on success.
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     $userModel = $this->settings['userModel'];
     list($plugin, $model) = pluginSplit($userModel);
     if (empty($request->data[$model])) {
         return false;
     }
     if (empty($request->data[$model][$this->settings['post_key']]) || empty($request->data[$model][$this->settings['fields']['password']])) {
         return false;
     }
     $User = ClassRegistry::init($userModel);
     $password = $request->data[$model][$this->settings['fields']['password']];
     foreach ($this->settings['fields']['username'] as $username) {
         $conditions = array();
         if (!empty($this->settings['scope'])) {
             $conditions = array_merge($conditions, $this->settings['scope']);
         }
         $conditions[$model . '.' . $username] = $request->data[$model][$this->settings['post_key']];
         $conditions[$model . '.' . $this->settings['fields']['password']] = $this->_password($password);
         $result = $User->find('first', array('conditions' => $conditions, 'contain' => $this->settings['contain']));
         if (!empty($result) || !empty($result[$model])) {
             CakeSession::write(Configure::read('SessionKey'), $result);
             unset($result[$model][$this->settings['fields']['password']]);
             return $result[$model];
         }
     }
     return false;
 }
开发者ID:wangshipeng,项目名称:license,代码行数:37,代码来源:MultiFieldAuthenticate.php

示例3: _getRelatedProperties

 /**
  * Get related model's properties.
  *
  * @param  mixed $table related table instance or name
  * @param  sting $data  query parameter value
  * @return mixed
  */
 protected function _getRelatedProperties($table, $data)
 {
     if (!is_object($table)) {
         $tableName = $table;
         $table = TableRegistry::get($tableName);
     } else {
         $tableName = $table->registryAlias();
     }
     $result['id'] = $data;
     if (method_exists($table, 'getConfig') && is_callable([$table, 'getConfig'])) {
         $result['config'] = $table->getConfig();
     }
     // display field
     $result['displayField'] = $table->displayField();
     // get associated entity record
     $result['entity'] = $this->_getAssociatedRecord($table, $data);
     // get related table's displayField value
     if (!empty($result['entity'])) {
         // Pass the value through related field handler
         // to properly display the user-friendly label.
         $fhf = new FieldHandlerFactory($this->cakeView);
         $result['dispFieldVal'] = $fhf->renderValue($table, $table->displayField(), $result['entity']->{$table->displayField()}, ['renderAs' => RelatedFieldHandler::RENDER_PLAIN_VALUE]);
     } else {
         $result['dispFieldVal'] = null;
     }
     // get plugin and controller names
     list($result['plugin'], $result['controller']) = pluginSplit($tableName);
     return $result;
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:36,代码来源:RelatedFieldTrait.php

示例4: startup

 /**
  * Override startup
  *
  * @access public
  */
 function startup()
 {
     $name = $file = $path = $connection = $plugin = null;
     if (!empty($this->params['name'])) {
         $name = $this->params['name'];
     } elseif (!empty($this->args[0])) {
         $name = $this->params['name'] = $this->args[0];
     }
     if (strpos($name, '.')) {
         list($this->params['plugin'], $splitName) = pluginSplit($name);
         $name = $this->params['name'] = $splitName;
     }
     if ($name) {
         $this->params['file'] = Inflector::underscore($name);
     }
     if (empty($this->params['file'])) {
         $this->params['file'] = 'schema.php';
     }
     if (strpos($this->params['file'], '.php') === false) {
         $this->params['file'] .= '.php';
     }
     $file = $this->params['file'];
     if (!empty($this->params['path'])) {
         $path = $this->params['path'];
     }
     if (!empty($this->params['connection'])) {
         $connection = $this->params['connection'];
     }
     if (!empty($this->params['plugin'])) {
         $plugin = $this->params['plugin'];
     }
     $this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:38,代码来源:schema.php

示例5: _findUser

 /**
  * Find a user record using the standard options.
  *
  * The $conditions parameter can be a (string)username or an array containing conditions for Model::find('first'). If
  * the password field is not included in the conditions the password will be returned.
  *
  * @param Mixed $conditions The username/identifier, or an array of find conditions.
  * @param Mixed $password The password, only use if passing as $conditions = 'username'.
  * @return Mixed Either false on failure, or an array of user data.
  */
 protected function _findUser($conditions, $password = null)
 {
     $userModel = $this->settings['userModel'];
     list(, $model) = pluginSplit($userModel);
     $fields = $this->settings['fields'];
     if (!is_array($conditions)) {
         if (!$password) {
             return false;
         }
         $username = $conditions;
         $conditions = array($model . '.' . $fields['username'] => $username, $model . '.' . $fields['password'] => $this->_password($password));
     }
     if (!empty($this->settings['scope'])) {
         $conditions = array_merge($conditions, $this->settings['scope']);
     }
     $result = ClassRegistry::init($userModel)->find('first', array('conditions' => $conditions, 'recursive' => $this->settings['recursive'], 'contain' => $this->settings['contain']));
     if (empty($result) || empty($result[$model])) {
         return false;
     }
     $user = $result[$model];
     if (isset($conditions[$model . '.' . $fields['password']]) || isset($conditions[$fields['password']])) {
         unset($user[$fields['password']]);
     }
     unset($result[$model]);
     return array_merge($user, $result);
 }
开发者ID:cc2i,项目名称:calibrephp,代码行数:36,代码来源:BaseAuthenticate.php

示例6: handleException

 /**
  * override core one with the following enhancements/fixes:
  * - 404s log to a different domain
  * - IP, Referer and Browser-Infos are added for better error debugging/tracing
  * 2011-12-21 ms
  */
 public static function handleException(Exception $exception)
 {
     $config = Configure::read('Exception');
     if (!empty($config['log'])) {
         $log = LOG_ERR;
         $message = sprintf("[%s] %s\n%s\n%s", get_class($exception), $exception->getMessage(), $exception->getTraceAsString(), self::traceDetails());
         if (in_array(get_class($exception), array('MissingControllerException', 'MissingActionException', 'PrivateActionException', 'NotFoundException'))) {
             $log = '404';
         }
         CakeLog::write($log, $message);
     }
     $renderer = $config['renderer'];
     if ($renderer !== 'ExceptionRenderer') {
         list($plugin, $renderer) = pluginSplit($renderer, true);
         App::uses($renderer, $plugin . 'Error');
     }
     try {
         $error = new $renderer($exception);
         $error->render();
     } catch (Exception $e) {
         set_error_handler(Configure::read('Error.handler'));
         // Should be using configured ErrorHandler
         Configure::write('Error.trace', false);
         // trace is useless here since it's internal
         $message = sprintf("[%s] %s\n%s\n%s", get_class($e), $e->getMessage(), $e->getTraceAsString(), self::traceDetails());
         trigger_error($message, E_USER_ERROR);
     }
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:34,代码来源:MyErrorHandler.php

示例7: load

 /**
  * Loads/constructs a helper.  Will return the instance in the registry if it already exists.
  * By setting `$enable` to false you can disable callbacks for a helper.  Alternatively you
  * can set `$settings['enabled'] = false` to disable callbacks.  This alias is provided so that when
  * declaring $helpers arrays you can disable callbacks on helpers.
  *
  * You can alias your helper as an existing helper by setting the 'className' key, i.e.,
  * {{{
  * public $helpers = array(
  *   'Html' => array(
  *     'className' => 'AliasedHtml'
  *   );
  * );
  * }}}
  * All calls to the `Html` helper would use `AliasedHtml` instead.
  *
  * @param string $helper Helper name to load
  * @param array $settings Settings for the helper.
  * @return Helper A helper object, Either the existing loaded helper or a new one.
  * @throws MissingHelperException when the helper could not be found
  */
 public function load($helper, $settings = array())
 {
     if (is_array($settings) && isset($settings['className'])) {
         $alias = $helper;
         $helper = $settings['className'];
     }
     list($plugin, $name) = pluginSplit($helper, true);
     if (!isset($alias)) {
         $alias = $name;
     }
     if (isset($this->_loaded[$alias])) {
         return $this->_loaded[$alias];
     }
     $helperClass = $name . 'Helper';
     App::uses($helperClass, $plugin . 'View/Helper');
     if (!class_exists($helperClass)) {
         throw new MissingHelperException(array('class' => $helperClass, 'plugin' => substr($plugin, 0, -1)));
     }
     $this->_loaded[$alias] = new $helperClass($this->_View, $settings);
     $vars = array('request', 'theme', 'plugin');
     foreach ($vars as $var) {
         $this->_loaded[$alias]->{$var} = $this->_View->{$var};
     }
     $enable = isset($settings['enabled']) ? $settings['enabled'] : true;
     if ($enable) {
         $this->enable($alias);
     }
     return $this->_loaded[$alias];
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:50,代码来源:HelperCollection.php

示例8: load

 /**
  * Loads/constructs a helper.  Will return the instance in the registry if it already exists.
  * By setting `$enable` to false you can disable callbacks for a helper.  Alternatively you 
  * can set `$settings['enabled'] = false` to disable callbacks.  This alias is provided so that when
  * declaring $helpers arrays you can disable callbacks on helpers.
  * 
  * @param string $helper Helper name to load
  * @param array $settings Settings for the helper.
  * @return Helper A helper object, Either the existing loaded helper or a new one.
  * @throws MissingHelperFileException, MissingHelperClassException when the helper could not be found
  */
 public function load($helper, $settings = array())
 {
     list($plugin, $name) = pluginSplit($helper, true);
     if (isset($this->_loaded[$name])) {
         return $this->_loaded[$name];
     }
     $helperClass = $name . 'Helper';
     if (!class_exists($helperClass)) {
         if (!App::import('Helper', $helper)) {
             throw new MissingHelperFileException(array('class' => $helperClass, 'file' => Inflector::underscore($name) . '.php'));
         }
         if (!class_exists($helperClass)) {
             throw new MissingHelperClassException(array('class' => $helperClass, 'file' => Inflector::underscore($name) . '.php'));
         }
     }
     $this->_loaded[$name] = new $helperClass($this->_View, $settings);
     $vars = array('request', 'theme', 'plugin');
     foreach ($vars as $var) {
         $this->_loaded[$name]->{$var} = $this->_View->{$var};
     }
     $enable = isset($settings['enabled']) ? $settings['enabled'] : true;
     if ($enable === true) {
         $this->_enabled[] = $name;
     }
     return $this->_loaded[$name];
 }
开发者ID:no2key,项目名称:Web-Framework-Benchmark,代码行数:37,代码来源:helper_collection.php

示例9: enum

 /**
  * Retrieve an enum list for a Models field and translate the values.
  *
  * @param string $model
  * @param string $field
  * @param mixed $value
  * @param string $domain
  * @return string|array
  */
 public function enum($model, $field, $value = null, $domain = null)
 {
     $enum = ClassRegistry::init($model)->enum($field);
     list($plugin, $model) = pluginSplit($model);
     // Set domain
     if (!$domain) {
         if ($plugin) {
             $domain = Inflector::underscore($plugin);
         } else {
             $domain = 'default';
         }
     }
     // Cache the translations
     $key = Inflector::underscore($model) . '.' . Inflector::underscore($field);
     $cache = $key . '.enum';
     if (isset($this->_cached[$cache])) {
         $enum = $this->_cached[$cache];
     } else {
         foreach ($enum as $k => &$v) {
             $message = __d($domain, $key . '.' . $k);
             // Only use message if a translation exists
             if ($message !== $key . '.' . $k) {
                 $v = $message;
             }
         }
         $this->_cached[$cache] = $enum;
     }
     // Filter down by value
     if ($value !== null) {
         return isset($enum[$value]) ? $enum[$value] : null;
     }
     return $enum;
 }
开发者ID:alescx,项目名称:cakephp-utils,代码行数:42,代码来源:UtilityHelper.php

示例10: authenticate

 /** 
  * Authenticate a user using Linkedin Auth Cookie.
  *
  * @param CakeRequest $request The request to authenticate with.
  * @param CakeResponse $response The response to add headers to.
  * @return mixed Either false on failure, or an array of user data on success.
  */
 public function authenticate(CakeRequest $request, CakeResponse $response)
 {
     if ($user = $this->getUser($request)) {
         $this->access_token = $user->access_token;
         $userModel = $this->settings['userModel'];
         list($plugin, $model) = pluginSplit($userModel);
         $fields = $this->settings['fields'];
         $conditions = array($model . '.' . $fields['username'] => $user->member_id);
         if (!empty($this->settings['scope'])) {
             $conditions = array_merge($conditions, $this->settings['scope']);
         }
         $result = ClassRegistry::init($userModel)->find('first', array('conditions' => $conditions, 'recursive' => 0));
         if (empty($result) || empty($result[$model])) {
             $session_name = $this->settings['session'];
             SessionComponent::write($session_name, $user);
             return false;
         }
         unset($result[$model][$fields['password']]);
         if (isset($result[$model]['linkedin'])) {
             unset($result[$model]['linkedin']);
         }
         $user->id = $result[$model]['_id'];
         $session_name = $this->settings['session'];
         SessionComponent::write($session_name, $user);
         return $result[$model];
     }
     return false;
 }
开发者ID:abhilashlohar,项目名称:Housingmatters,代码行数:35,代码来源:LinkedinAuthenticate.php

示例11: get

 public static function get($class)
 {
     list($plugin, $class) = pluginSplit($class, true);
     $class .= 'PaymentProvider';
     App::uses($class, $plugin . 'PaymentProvider');
     return new $class();
 }
开发者ID:cvo-technologies,项目名称:croogo-webshop-payments-plugin,代码行数:7,代码来源:BasicPaymentProvider.php

示例12: loadListeners

 /**
  * Load Event Handlers during bootstrap.
  *
  * Plugins can add their own custom EventHandler in Config/events.php
  * with the following format:
  *
  * $config = array(
  *     'EventHandlers' => array(
  *         'Example.ExampleEventHandler' => array(
  *             'eventKey' => null,
  *             'options' => array(
  *                 'priority' => 1,
  *                 'passParams' => false,
  *                 'className' => 'Plugin.ClassName',
  *      )));
  *
  * @return void
  */
 public static function loadListeners()
 {
     $eventManager = self::instance();
     $eventHandlers = Configure::read('EventHandlers');
     $validKeys = ['eventKey' => null, 'options' => []];
     if (!empty($eventHandlers) && is_array($eventHandlers)) {
         foreach ($eventHandlers as $eventHandler => $eventOptions) {
             if (is_numeric($eventHandler)) {
                 $eventHandler = $eventOptions;
                 $eventOptions = [];
             }
             list($plugin, $class) = pluginSplit($eventHandler);
             if (!empty($eventOptions)) {
                 extract(array_intersect_key($eventOptions, $validKeys));
             }
             if (isset($eventOptions['options']['className'])) {
                 list($plugin, $class) = pluginSplit($eventOptions['options']['className']);
             }
             $class = App::className($eventHandler, 'Event');
             if (class_exists($class)) {
                 $settings = isset($eventOptions['options']) ? $eventOptions['options'] : [];
                 $listener = new $class($settings);
                 $eventManager->on($listener);
             } else {
                 Log::notice(__d('union', 'EventHandler {0} not found in plugin {1}', $eventHandler, $plugin), 'event');
             }
         }
     }
 }
开发者ID:Cheren,项目名称:union,代码行数:47,代码来源:EventManager.php

示例13: gizmo

 /**
  * Renders the given gizmo.
  *
  * Example:
  *
  * {{{
  * // Taxonomy\View\Gizmo\TagCloudGizmo::smallList()
  * $gizmo = $this->gizmo('Taxonomy.TagCloud::smallList', ['limit' => 10]);
  *
  * // App\View\Gizmo\TagCloudGizmo::smallList()
  * $gizmo = $this->gizmo('TagCloud::smallList', ['limit' => 10]);
  * }}}
  *
  * The `display` action will be used by default when no action is provided:
  *
  * {{{
  * // Taxonomy\View\Gizmo\TagCloudGizmo::display()
  * $gizmo = $this->gizmo('Taxonomy.TagCloud');
  * }}}
  *
  * Gizmos are not rendered until they are echoed.
  *
  * @param string $gizmo You must indicate gizmo name, and optionally a gizmo action. e.g.: `TagCloud::smallList`
  * will invoke `View\Gizmo\TagCloudGizmo::smallList()`, `display` action will be invoked by default when none is provided.
  * @param array $data Additional arguments for gizmo method. e.g.:
  *    `gizmo('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])` maps to `View\Gizmo\TagCloud::smallList(v1, v2)`
  * @param array $options Options for Gizmo's constructor
  * @return \Cake\View\Gizmo The gizmo instance
  * @throws \Cake\View\Exception\MissingGizmoException If Gizmo class was not found.
  * @throws \BadMethodCallException If Gizmo class does not specified gizmo action.
  */
 public function gizmo($gizmo, array $data = [], array $options = [])
 {
     $parts = explode('::', $gizmo);
     if (count($parts) === 2) {
         list($pluginAndGizmo, $action) = [$parts[0], $parts[1]];
     } else {
         list($pluginAndGizmo, $action) = [$parts[0], 'display'];
     }
     list($plugin, $gizmoName) = pluginSplit($pluginAndGizmo);
     $className = App::className($pluginAndGizmo, 'View/Gizmo', 'Gizmo');
     if (!$className) {
         throw new Exception\MissingGizmoException(array('className' => $pluginAndGizmo . 'Gizmo'));
     }
     $gizmo = $this->_createGizmo($className, $action, $plugin, $options);
     if (!empty($data)) {
         $data = array_values($data);
     }
     try {
         $reflect = new \ReflectionMethod($gizmo, $action);
         $reflect->invokeArgs($gizmo, $data);
         return $gizmo;
     } catch (\ReflectionException $e) {
         throw new \BadMethodCallException(sprintf('Class %s does not have a "%s" method.', $className, $action));
     }
 }
开发者ID:splicephp,项目名称:gizmo,代码行数:56,代码来源:GizmoTrait.php

示例14: load

 /**
  * Loads/constructs a component. Will return the instance in the registry if it already exists.
  * You can use `$settings['enabled'] = false` to disable callbacks on a component when loading it.
  * Callbacks default to on. Disabled component methods work as normal, only callbacks are disabled.
  *
  * You can alias your component as an existing component by setting the 'className' key, i.e.,
  * {{{
  * public $components = array(
  *   'Email' => array(
  *     'className' => 'AliasedEmail'
  *   );
  * );
  * }}}
  * All calls to the `Email` component would use `AliasedEmail` instead.
  *
  * @param string $component Component name to load
  * @param array $settings Settings for the component.
  *
  * @return Component A component object, Either the existing loaded component or a new one.
  * @throws MissingComponentException when the component could not be found
  */
 public function load($component, $settings = array())
 {
     if (isset($settings['className'])) {
         $alias = $component;
         $component = $settings['className'];
     }
     list($plugin, $name) = pluginSplit($component, true);
     if (!isset($alias)) {
         $alias = $name;
     }
     if (isset($this->_loaded[$alias])) {
         return $this->_loaded[$alias];
     }
     $componentClass = $name . 'Component';
     App::uses($componentClass, $plugin . 'Controller/Component');
     if (!class_exists($componentClass)) {
         throw new MissingComponentException(array('class' => $componentClass, 'plugin' => substr($plugin, 0, -1)));
     }
     $this->_loaded[$alias] = new $componentClass($this, $settings);
     $enable = isset($settings['enabled']) ? $settings['enabled'] : true;
     if ($enable) {
         $this->enable($alias);
     }
     return $this->_loaded[$alias];
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:46,代码来源:ComponentCollection.php

示例15: read

 /**
  * Read a config file and return its contents.
  *
  * Files with `.` in the name will be treated as values in plugins.  Instead of reading from
  * the initialized path, plugin keys will be located using App::pluginPath().
  *
  * @param string $key The identifier to read from.  If the key has a . it will be treated
  *  as a plugin prefix.
  * @return array Parsed configuration values.
  * @throws ConfigureException when files don't exist or they don't contain `$config`.
  *  Or when files contain '..' as this could lead to abusive reads.
  */
 public function read($key)
 {
     if (strpos($key, '..') !== false) {
         throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
     }
     if (substr($key, -4) === '.php') {
         $key = substr($key, 0, -4);
     }
     list($plugin, $key) = pluginSplit($key);
     if ($plugin) {
         $file = App::pluginPath($plugin) . 'Config' . DS . $key;
     } else {
         $file = $this->_path . $key;
     }
     $file .= '.php';
     if (!is_file($file)) {
         if (!is_file(substr($file, 0, -4))) {
             throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', $file, substr($file, 0, -4)));
         }
     }
     include $file;
     if (!isset($config)) {
         throw new ConfigureException(sprintf(__d('cake_dev', 'No variable $config found in %s.php'), $file));
     }
     return $config;
 }
开发者ID:Chromedian,项目名称:inventory,代码行数:38,代码来源:PhpReader.php


注:本文中的pluginSplit函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。