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


PHP DiInterface::get方法代码示例

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


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

示例1: registerServices

 public function registerServices(\Phalcon\DiInterface $di)
 {
     //registrando annotations
     $this->registerAnnotationsFiles(['Column', 'Entity', 'GeneratedValue', 'HasLifecycleCallbacks', 'Id', 'PrePersist', 'PreUpdate', 'Table', 'ManyToOne', 'ManyToMany', 'JoinTable', 'JoinColumn']);
     //configurando entity manager
     $di->setShared('entityManager', function () use($di) {
         $infraConfig = $di->get('Infrastructure\\Config');
         //            $doctrine_config = Setup::createAnnotationMetadataConfiguration($infraConfig['ormMapper'], $di->get('App\Config')['devmode']);
         $config = Setup::createConfiguration($di->get('App\\Config')['devmode']);
         $driver = new AnnotationDriver(new AnnotationReader(), $infraConfig['ormMapper']);
         // registering noop annotation autoloader - allow all annotations by default
         AnnotationRegistry::registerLoader('class_exists');
         $config->setMetadataDriverImpl($driver);
         $entityManager = EntityManager::create($infraConfig['databases'][0], $config);
         $platform = $entityManager->getConnection()->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('enum', 'string');
         return $entityManager;
     });
     $di->setShared('api', function () use($di) {
         $infraConfig = $di->get('Infrastructure\\Config');
         return new Service\RESTClient($infraConfig['baseUrl']['api'], $infraConfig['credentials']);
     });
     $di->setShared('geocodeApi', function () use($di) {
         return new Service\RESTClient('https://maps.googleapis.com/maps/api/geocode/json?&key=AIzaSyBwFWzpssaahZ7SfLZt6mv7PeZBFXImpmo&address=');
     });
 }
开发者ID:silverwolfx10,项目名称:tcc-uhealth,代码行数:26,代码来源:Module.php

示例2: 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

示例3: registerServices

 /**
  * Register specific services for the module
  */
 public function registerServices(DiInterface $di)
 {
     $config = $di->get('config');
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Promoziti\\Modules\\Business\\Controllers");
         return $dispatcher;
     });
     $di->set('view', function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         $view->registerEngines(array('.volt' => function ($view, $di) {
             $volt = new VoltEngine($view, $di);
             $config = $di->get('config');
             $volt->setOptions(array('compileAlways' => true, 'compiledPath' => $config->application->cache_dir . "volt/", 'compiledSeparator' => '_'));
             return $volt;
         }));
         return $view;
     });
     $di->set('aws_s3', function () use($config) {
         //version 2.7 style
         $s3 = \Aws\S3\S3Client::factory(array('key' => $config->application->security->aws->key, 'secret' => $config->application->security->aws->secret, 'region' => 'us-west-2', 'version' => '2006-03-01'));
         return $s3;
     });
 }
开发者ID:corzoit,项目名称:phalcon-boilerplate,代码行数:29,代码来源:Module.php

示例4: 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

示例5: 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

示例6: register

 /**
  * {@inheritdoc}
  */
 public function register(DiInterface $di)
 {
     $di->set(self::SERVICE_NAME, function () use($di) {
         $adapter = new \Vegas\Security\Authentication\Adapter\Standard($di->get('userPasswordManager'));
         $adapter->setSessionStorage($di->get('sessionManager')->createScope('auth'));
         $auth = new \Vegas\Security\Authentication($adapter);
         return $auth;
     }, true);
 }
开发者ID:maniolek,项目名称:demo,代码行数:12,代码来源:AuthServiceProvider.php

示例7: registerAutoloaders

 public function registerAutoloaders(\Phalcon\DiInterface $manager = NULL)
 {
     $loader = new Loader();
     $loader->registerNamespaces(array(ucfirst($this->moduleName) . '\\Controllers' => __DIR__ . '/controllers/', 'Multiple\\Components' => APPLICATION_PATH . $manager->get('config')->application->componentsDir, 'Multiple\\Models' => APPLICATION_PATH . $manager->get('config')->application->modelsDir, 'Multiple\\Plugins' => APPLICATION_PATH . $manager->get('config')->application->pluginsDir));
     $loader->register();
     $manager->set('logger', function () use($manager) {
         $monthNow = date("Y-m-d", time());
         $pathLog = APPLICATION_PATH . $manager->get('config')->application->logsDir . '/' . $this->moduleName . '/' . $monthNow . '.log';
         $logger = new LogFile($pathLog);
         return $logger;
     });
 }
开发者ID:phalcon-id,项目名称:phalcon2-rest-api,代码行数:12,代码来源:Module.php

示例8: registerServices

 public function registerServices(DiInterface $di = null)
 {
     $dispatcher = $di->get('dispatcher');
     $dispatcher->setDefaultNamespace('Admin\\Controller');
     /**
      * @var $view \Phalcon\Mvc\View
      */
     $view = $di->get('view');
     $view->setLayout('index');
     $view->setViewsDir(APPLICATION_PATH . '/modules/admin/views/');
     $view->setLayoutsDir('../../common/layouts/');
     $view->setPartialsDir('../../common/partials/');
     $di->set('view', $view);
 }
开发者ID:TheCodemasterZz,项目名称:phalcon-module-skeleton,代码行数:14,代码来源:Module.php

示例9: verifyNon

 /**
  * 判断是否在不需要判断权限列表中
  * @param \Phalcon\DiInterface $di
  * @param string $controllerName
  * @param string $actionName
  * @return bool
  */
 private static function verifyNon($controllerName, $actionName, $di)
 {
     $controllerName = is_string($controllerName) ? strtolower($controllerName) : $controllerName;
     $actionName = is_string($actionName) ? strtolower($actionName) : $actionName;
     $nonVerifyRight = $di->get('appConfig') && $di->get('appConfig')->offsetExists('operator') && $di->get('appConfig')->operator->offsetExists('nonVerifyRight') ? $di->get('appConfig')->operator->nonVerifyRight->toArray() : null;
     if ($nonVerifyRight == null) {
         $nonVerifyRight = $di->get('moduleConfig') && $di->get('moduleConfig')->offsetExists('operator') && $di->get('moduleConfig')->operator->offsetExists('nonVerifyRight') ? $di->get('moduleConfig')->operator->nonVerifyRight->toArray() : null;
     }
     $nonVerifyRight = $nonVerifyRight == null ? [] : $nonVerifyRight;
     foreach ($nonVerifyRight as $k => $v) {
         if (strtolower($k) == $controllerName) {
             if ($actionName == null) {
                 return true;
             }
             if (is_string($v)) {
                 if ($v == '*' || strtolower($v) == $actionName) {
                     return true;
                 }
             } else {
                 if (in_array($actionName, $v)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:fu-tao,项目名称:meelier_c,代码行数:34,代码来源:GroupRight.php

示例10: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $module_config = (include APP_PATH . "/apps/cliente/config/config.php");
     $di->get('config')->merge($module_config);
     $config = $di->get('config');
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         return new DbAdapter($config->database->toArray());
     };
 }
开发者ID:zedmaster,项目名称:ticobox,代码行数:20,代码来源:Module.php

示例11: __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

示例12: register

 /**
  * {@inheritdoc}
  */
 public function register(DiInterface $di)
 {
     $di->set(self::SERVICE_NAME, function () use($di) {
         $session = new Vegas\Session($di->get('session'));
         return $session;
     }, true);
 }
开发者ID:vegas-cmf,项目名称:profiler,代码行数:10,代码来源:SessionManagerServiceProvider.php

示例13: register

 /**
  * {@inheritdoc}
  */
 public function register(DiInterface $di)
 {
     $di->set(self::SERVICE_NAME, function () use($di) {
         $config = $di->get('config');
         return new Phalcon\Db\Adapter\Pdo\Mysql(["host" => $config->database->host, "dbname" => $config->database->dbname, "port" => $config->database->port, "username" => $config->database->username, "password" => $config->database->password, "options" => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']]);
     }, true);
 }
开发者ID:maniolek,项目名称:demo,代码行数:10,代码来源:DbServiceProvider.php

示例14: register

 /**
  * {@inheritdoc}
  * @see http://docs.phalconphp.com/en/latest/api/Phalcon_Db_Adapter_Pdo_Sqlite.html
  */
 public function register(DiInterface $di)
 {
     $di->set(self::SERVICE_NAME, function () use($di) {
         $config = $di->get('config');
         return new Phalcon\Db\Adapter\Pdo\Sqlite(array("dbname" => $config->db->dbname));
     }, true);
 }
开发者ID:maniolek,项目名称:vegaser,代码行数:11,代码来源:SqliteServiceProvider.php

示例15: registerServices

 /**
  * Registers the module-only services
  *
  * @param \Phalcon\DiInterface $di
  */
 public function registerServices($di)
 {
     /**
      * Read application wide and module only configurations
      */
     $appConfig = $di->get('config');
     $moduleConfig = (include __DIR__ . '/config/config.php');
     $di->set('moduleConfig', $moduleConfig);
     /**
      * The URL component is used to generate all kind of urls in the application
      */
     $di->set('url', function () use($appConfig) {
         $url = new UrlResolver();
         $url->setBaseUri($appConfig->application->baseUri);
         return $url;
     });
     /**
      * Module specific dispatcher
      */
     $di->set('dispatcher', function () use($di) {
         $dispatcher = new Dispatcher();
         $dispatcher->setEventsManager($di->getShared('eventsManager'));
         $dispatcher->setDefaultNamespace('App\\Modules\\Oauth\\');
         return $dispatcher;
     });
     /**
      * Module specific database connection
      */
     $di->set('db', function () use($appConfig) {
         return new DbAdapter(['host' => $moduleConfig->database->host, 'username' => $moduleConfig->database->username, 'password' => $moduleConfig->database->password, 'dbname' => $moduleConfig->database->name]);
     });
 }
开发者ID:sarahsampan,项目名称:compare-api,代码行数:37,代码来源:Module.php


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