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


PHP DiInterface::has方法代码示例

本文整理汇总了PHP中Phalcon\DiInterface::has方法的典型用法代码示例。如果您正苦于以下问题:PHP DiInterface::has方法的具体用法?PHP DiInterface::has怎么用?PHP DiInterface::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\DiInterface的用法示例。


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

示例1: get

 /**
  * @param string $name
  * @return mixed
  * @throws \Exception
  */
 public function get($name)
 {
     if ($this->di->has($name)) {
         return $this->di->get($name);
     }
     throw new \Exception("Service \"{$name}\" is not defined");
 }
开发者ID:serebro,项目名称:reach-common,代码行数:12,代码来源:Phalcon.php

示例2: registerConfig

 protected function registerConfig()
 {
     $config = (require __DIR__ . '/config/config.php');
     if ($this->di->has('console.config')) {
         $config->merge($this->di->get('console.config'));
     }
     $this->di['console.config'] = $config;
 }
开发者ID:TheCodemasterZz,项目名称:phalcon-console,代码行数:8,代码来源:ConsoleService.php

示例3: __construct

 /**
  * Constructor. Allows you to specify the initial settings for the widget.
  * Parameters can be passed as an associative array.
  * Also, the parameters can be set using the appropriate methods
  *
  * @param array $params
  * @throws \Phalcon\DI\Exception
  * @throws \Phalcon\Session\Exception
  */
 public function __construct(array $params = [])
 {
     if (DI::getDefault() === null) {
         throw new \Phalcon\DI\Exception('DI is not configured!');
     }
     if ($this->hasSession() === false) {
         throw new Exception('Session does not configured in DI');
     }
     if ($this->session->has(self::KEY) === true) {
         $this->user = $this->session->get(self::KEY);
     } else {
         $this->user = false;
     }
     parent::__construct($params);
 }
开发者ID:stanislav-web,项目名称:phalcon-ulogin,代码行数:24,代码来源:Auth.php

示例4: collect

 /**
  * Called by the DebugBar when data needs to be collected
  * @return array Collected data
  */
 function collect()
 {
     $request = $this->request;
     $response = $this->response;
     $status = $response->getHeaders()->get('Status') ?: '200 ok';
     $responseHeaders = $response->getHeaders()->toArray() ?: headers_list();
     $cookies = $_COOKIE;
     unset($cookies[session_name()]);
     $cookies_service = $response->getCookies();
     if ($cookies_service) {
         $useEncrypt = true;
         if ($cookies_service->isUsingEncryption() && $this->di->has('crypt') && !$this->di['crypt']->getKey()) {
             $useEncrypt = false;
         }
         if (!$cookies_service->isUsingEncryption()) {
             $useEncrypt = false;
         }
         foreach ($cookies as $key => $vlaue) {
             $cookies[$key] = $cookies_service->get($key)->useEncryption($useEncrypt)->getValue();
         }
     }
     $data = array('status' => $status, 'request_query' => $request->getQuery(), 'request_post' => $request->getPost(), 'request_body' => $request->getRawBody(), 'request_cookies' => $cookies, 'request_server' => $_SERVER, 'response_headers' => $responseHeaders, 'response_body' => $request->isAjax() ? $response->getContent() : '');
     if (Version::getId() < 2000000 && $request->isAjax()) {
         $data['request_headers'] = '';
         // 1.3.x has a ajax bug , so we use empty string insdead.
     } else {
         $data['request_headers'] = $request->getHeaders();
     }
     $data = array_filter($data);
     if (isset($data['request_query']['_url'])) {
         unset($data['request_query']['_url']);
     }
     if (empty($data['request_query'])) {
         unset($data['request_query']);
     }
     if (isset($data['request_headers']['php-auth-pw'])) {
         $data['request_headers']['php-auth-pw'] = '******';
     }
     if (isset($data['request_server']['PHP_AUTH_PW'])) {
         $data['request_server']['PHP_AUTH_PW'] = '******';
     }
     foreach ($data as $key => $var) {
         if (!is_string($data[$key])) {
             $data[$key] = $this->formatVar($var);
         }
     }
     return $data;
 }
开发者ID:minhlaoleu,项目名称:phalcon-debugbar,代码行数:52,代码来源:PhalconRequestCollector.php

示例5: getApplication

 /**
  * @param \Phalcon\DiInterface $di
  *
  * @return \Phalcon\Mvc\Application
  */
 protected function getApplication(\Phalcon\DiInterface $di)
 {
     if (!$di->has("application")) {
         return $this->getDefaultApplication($di);
     }
     return $di->get("application");
 }
开发者ID:sidroberts,项目名称:phalcon-application,代码行数:12,代码来源:Web.php

示例6: getConsole

 /**
  * @param \Phalcon\DiInterface $di
  *
  * @return \Phalcon\Cli\Console
  */
 protected function getConsole(\Phalcon\DiInterface $di)
 {
     if (!$di->has("console")) {
         return $this->getDefaultConsole($di);
     }
     return $di->get("console");
 }
开发者ID:sidroberts,项目名称:phalcon-application,代码行数:12,代码来源:Cli.php

示例7: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * 获取全局配置
      */
     $config = $di->has('config') ? $di->getShared('config') : null;
     /**
      * 各模块可自定义config文件并替换全局的config配置
      */
     if (file_exists($this->modulePath . '/config/config.php')) {
         $override = new Config(include $this->modulePath . '/config/config.php');
         if ($config instanceof Config) {
             $config->merge($override);
         } else {
             $config = $override;
         }
     }
     //重置全局配置
     $di->setShared('config', $config);
     /**
      * 设置各个模块的视图目录
      */
     $view = new View();
     //$view->setViewsDir($this->modulePath . '/views/default/');
     $view->setViewsDir(FRONTEND_PUBLIC_PATH . 'views/default/');
     $view->registerEngines(['.volt' => 'volt', '.php' => 'volt', '.html' => 'volt']);
     $di->set('view', $view);
 }
开发者ID:ylh990835774,项目名称:phalcon_ydjc,代码行数:33,代码来源:BaseModule.php

示例8: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read common configuration
      */
     $config = $di->has('config') ? $di->getShared('config') : null;
     /**
      * Try to load local configuration
      */
     if (file_exists(__DIR__ . '/config/config.php')) {
         $override = new Config(include __DIR__ . '/config/config.php');
         if ($config instanceof Config) {
             $config->merge($override);
         } else {
             $config = $override;
         }
     }
     /**
      * Setting up the view component
      */
     $view = $di->get('view');
     $view->setViewsDir($config->get('application')->viewsDir);
     $di->set('view', $view);
     // add default namespace
     $dispatcher = $di->get('dispatcher');
     $dispatcher->setDefaultNamespace("Application\\Frontend\\Controllers");
     $di->set('dispatcher', $dispatcher);
 }
开发者ID:zhangkg,项目名称:phalcon_manage,代码行数:33,代码来源:Module.php

示例9: setupExtraServices

 /**
  * Setups extra services (if not exist) required by mongo service
  *
  * @param DiInterface $di
  */
 public function setupExtraServices(DiInterface $di)
 {
     if (!$di->has('collectionManager')) {
         $di->set('collectionManager', function () {
             return new Manager();
         });
     }
 }
开发者ID:arius86,项目名称:core,代码行数:13,代码来源:AdapterTrait.php

示例10: hasService

 /**
  * Checks if a service is registered in the DI
  *
  * @param string $serviceName
  * @return boolean
  * @throws Exception
  */
 public function hasService($serviceName)
 {
     if (is_string($serviceName) === false) {
         throw new Exception('Invalid parameter type.');
     }
     if (is_object($this->_dependencyInjector) === false) {
         $this->_dependencyInjector = new FactoryDefault();
     }
     return $this->_dependencyInjector->has($serviceName);
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:17,代码来源:Micro.php

示例11: setDI

 /**
  * Sets the DependencyInjector container
  */
 public function setDI(DiInterface $dependencyInjector)
 {
     /**
      * We automatically set ourselves as application service
      */
     if (!$dependencyInjector->has("application")) {
         $dependencyInjector->set("application", $this);
     }
     $this->_dependencyInjector = $dependencyInjector;
 }
开发者ID:snowair,项目名称:phalcon-app,代码行数:13,代码来源:Micro.php

示例12: send

 /**
  * Sends the cookie to the HTTP client
  * Stores the cookie definition in session
  *
  * @return \Phalcon\Http\Cookie
  * @throws Exception
  */
 public function send()
 {
     //@note no interface validation
     if (is_object($this->_dependencyInjector) === true) {
         if ($this->_dependencyInjector->has('session') === true) {
             $definition = array();
             if ($this->_expire !== 0) {
                 $definition['expire'] = $this->_expire;
             }
             if (empty($this->_path) === false) {
                 $definition['path'] = $this->_path;
             }
             if (empty($this->_domain) === false) {
                 $definition['domain'] = $this->_domain;
             }
             if (empty($this->_secure) === false) {
                 $definition['secure'] = $this->_secure;
             }
             if (empty($this->_httpOnly) === false) {
                 $definition['httpOnly'] = $this->_httpOnly;
             }
             //The definition is stored in session
             if (count($definition) !== 0) {
                 $session = $this->_dependencyInjector->getShared('session');
                 if (is_null($session) === false) {
                     if ($session instanceof SessionInterface === false) {
                         throw new Exception('Wrong session service.');
                     }
                     $session->set('_PHCOOKIE_' . $this->_name, $definition);
                 }
             }
         }
     }
     /* Encryption */
     if ($this->_useEncryption === true && empty($this->_value) === false) {
         if (is_object($this->_dependencyInjector) === false) {
             //@note wrong exception message
             throw new Exception("A dependency injection object is required to access the 'filter' service");
         }
         $crypt = $this->_dependencyInjector->getShared('crypt');
         if ($crypt instanceof CryptInterface === false) {
             throw new Exception('Wrong crypt service.');
         }
         //Encrypt the value also coding it with base64
         $value = $crypt->encryptBase64($this->_value);
     }
     //Sets the cookie using the standard 'setcookie' function
     //@note use 'bool' as type for the last two parameter
     setcookie((string) $this->_name, (string) $value, (int) $this->_expire, (string) $this->_path, (string) $this->_domain, (bool) $this->_secure, (bool) $this->_httpOnly);
     return $this;
 }
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:58,代码来源:Cookie.php

示例13: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read common configuration
      */
     $config = $di->has('config') ? $di->getShared('config') : null;
     /**
      * Try to load local configuration
      */
     if (file_exists(__DIR__ . '/config/config.php')) {
         $override = new Config(include __DIR__ . '/config/config.php');
         if ($config instanceof Config) {
             $config->merge($override);
         } else {
             $config = $override;
         }
     }
     /**
      * Setting up the view component
      */
     $view = $di->get('view');
     $view->setViewsDir($config->get('application')->viewsDir);
     $di->set('view', $view);
     // register helper
     $di->setShared('adminHelper', function () {
         return new \Application\Admin\Librarys\voltHelper();
     });
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         $config = $config->database->toArray();
         $dbAdapter = '\\Phalcon\\Db\\Adapter\\Pdo\\' . $config['adapter'];
         unset($config['adapter']);
         return new $dbAdapter($config);
     };
     // add default namespace
     $dispatcher = $di->get('dispatcher');
     $dispatcher->setDefaultNamespace("Application\\Admin\\Controllers");
     $di->set('dispatcher', $dispatcher);
     // register menu
     $di->set('AdminMenus', function () {
         return require __DIR__ . '/config/menus.php';
     });
 }
开发者ID:PassionZale,项目名称:phalcon_manage,代码行数:50,代码来源:Module.php

示例14: getModelIdentity

 /**
  * Get identity.
  *
  * @param \Phalcon\Mvc\Model $model
  * @return mixed
  */
 protected function getModelIdentity(PhalconModel $model)
 {
     if (property_exists($model, 'id')) {
         return $model->id;
     }
     if (!$this->di->has('modelsMetadata')) {
         return null;
     }
     $primaryKeys = $this->di->get('modelsMetadata')->getPrimaryKeyAttributes($model);
     switch (count($primaryKeys)) {
         case 0:
             return null;
         case 1:
             return $model->{$primaryKeys[0]};
         default:
             return array_intersect_key(get_object_vars($model), array_flip($primaryKeys));
     }
 }
开发者ID:codeception,项目名称:base,代码行数:24,代码来源:Phalcon1.php

示例15: initialize

 /**
  * @param \Phalcon\DiInterface $di
  * @return mixed
  */
 public function initialize(\Phalcon\DiInterface $di)
 {
     /** @var \Phalcon\Config $config */
     $config = $di->get('config');
     $viewConfig = isset($config->application->view) ? $config->application->view->toArray() : [];
     if ($di->has('view')) {
         /** @var \Phalcon\Mvc\View $view */
         $view = $di->get('view');
         $viewEngines = $view->getRegisteredEngines();
         if (!$viewEngines) {
             $viewEngines = [];
         }
         $viewEngines['.twig'] = function ($this, $di) use($viewConfig) {
             return new \Phalcon\Mvc\View\Engine\Twig($this, $di, $viewConfig);
         };
         $view->registerEngines($viewEngines);
     }
 }
开发者ID:vegas-cmf,项目名称:mvc,代码行数:22,代码来源:Twig.php


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