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


PHP FactoryDefault::get方法代码示例

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


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

示例1: get

 public function get($routeName, $routeParams = array())
 {
     $url = $this->di->get('url');
     $options = array('for' => $routeName);
     $options = array_merge($options, $routeParams);
     return $url->get($options);
 }
开发者ID:sb15,项目名称:phalcon-ext,代码行数:7,代码来源:UrlHelper.php

示例2: get

 public function get($alias, $parameters = null)
 {
     $result = parent::get($alias, $parameters);
     $injector = new \Vegas\Mvc\Di\Manager();
     $injector->setDI($this);
     $injector->inject($result);
     return $result;
 }
开发者ID:vegas-cmf,项目名称:mvc,代码行数:8,代码来源:Di.php

示例3: __construct

 /**
  * Inject of Phalcon dependency container
  *
  * @param \Phalcon\DI\FactoryDefault $dependency
  * @throws BaseException
  */
 public function __construct(\Phalcon\DI\FactoryDefault $dependency)
 {
     if ($dependency->has('config') === true) {
         $this->config = $dependency->get('config')->sms->toArray();
     } else {
         throw new BaseException('SMS', 'Please setup your configuration to $dependency', 500);
     }
 }
开发者ID:shatkovskiy,项目名称:phalcon-sms-factory,代码行数:14,代码来源:Sender.php

示例4: get

 public function get($name, $parameters = [])
 {
     if ($this->router == null) {
         //$this->router = $this->getShared ( 'router' );
         $this->router = parent::get('router');
         $this->_init = true;
     }
     if ($this->_init) {
         $this->checkPermission($name);
     }
     return parent::get($name, $parameters);
 }
开发者ID:skullab,项目名称:thunderhawk,代码行数:12,代码来源:DI.php

示例5: setUp

 public function setUp()
 {
     $this->task = new ImportDmmTask();
     $di = new Di\FactoryDefault();
     $db = function () {
         return new Mysql(array("host" => $GLOBALS['db_host'], "username" => $GLOBALS['db_username'], "password" => $GLOBALS['db_password'], "dbname" => 'yinxing'));
     };
     $di->set('dbSlave', $db);
     $di->set('dbMaster', $db);
     $di->set('moduleManager', function () {
         return new ModuleManager();
     });
     /** @var Mysql $mysql */
     $mysql = $di->get('dbMaster');
     $mysql->query(file_get_contents(__DIR__ . '/../../sql/evamovie_2015-10-20.sql'));
 }
开发者ID:AlloVince,项目名称:yinxing,代码行数:16,代码来源:DmmHtmlTest.php

示例6: registerViewService

 /**
  * @param \Phalcon\DI\FactoryDefault     $di
  */
 protected function registerViewService($di)
 {
     /**
      * Setting up the view component
      */
     $di['view'] = function () use($di) {
         /*
          * Obtengo el nombre del modulo para poder obner el archivo de configuracion
          */
         $module = $this->name;
         $this->layout_dir = '../../../../public/layouts/' . $di->get('modules')->{$module}->layout . '/';
         $view = new View();
         $view->setViewsDir($this->path . $this->view_dir);
         $view->setLayoutsDir($this->layout_dir);
         $view->setTemplateAfter($this->template);
         $view->setVar('project-setting', $di->get('config')->project->toArray());
         /*
          * Registra Constantes de Modulo
          */
         $view->setVar('module-setting', $di->get('modules')->{$module}->toArray());
         // Set the engine
         $view->registerEngines(array(".mustache" => function ($view, DI $di) {
             $module = $this->name;
             $partial_url = '../public/layouts/' . $di->get('modules')->{$module}->layout . '/partials';
             $partial_loader = new Mustache_Loader_FilesystemLoader($partial_url);
             $config = $di->get('config')->cache->frontend;
             if ($config->active == 0) {
                 $options = array('partials_loader' => $partial_loader);
             } else {
                 $options = array('cache' => '/var/www/var/cache/elephant', 'cache_file_mode' => $config->mode, 'partials_loader' => $partial_loader, 'strict_callables' => $config->callables);
             }
             $mustache = new Mustache($view, $di, $options);
             return $mustache;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     };
 }
开发者ID:Jonhathan-Rodas,项目名称:elephant,代码行数:40,代码来源:Module.php

示例7: FactoryDefault

<?php

use Phalcon\Mvc\View\Simple as SimpleView;
use Phalcon\Di\FactoryDefault;
use Phalcon\Config\Adapter\Php as PhpConfig;
$di = new FactoryDefault();
$di->set('config', function () {
    $config = new PhpConfig(__DIR__ . '/app.php');
    if (is_readable(__DIR__ . '/app.development.php') && getenv('APPLICATION_ENV') == 'development') {
        $development = new PhpConfig(__DIR__ . '/app.development.php');
        $config->merge($development);
    }
    return $config;
}, true);
$di->set('view', function () use($di) {
    $config = $di->get('config')['view'];
    $view = new SimpleView();
    $view->setViewsDir($config['dir']);
    $view->setVar('appConfig', $di->get('config')['app']);
    $view->setVar('flashSession', $di->get('flashSession'));
    $engine = new $config['engine']($view);
    $engine->setOptions([$config['options']]);
    $view->registerEngines([$config['prefix'] => $engine]);
    return $view;
}, true);
$di->set('connection', function () use($di) {
    $config = $di->get('config')['database'];
    $adapter = new $config->adapter(["host" => $config->host, "username" => $config->username, "password" => $config->password, "dbname" => $config->db]);
    return $adapter;
}, true);
开发者ID:caiofralmeida,项目名称:soccer-company-event,代码行数:30,代码来源:services.php

示例8: function

});
/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->set('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Start the session the first time some component request the session service
 */
$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$language = $di->get("session")->get("language");
//Set default language
if (!$language) {
    $language = 'es';
}
$di->set('translate', function () use($config, $language) {
    // Ask browser what is the best language
    $request = new Request();
    //echo "language". $dispatcher->getParam('language');
    $translation = Translation::findBylanguagecode($language)->toArray();
    $messages = array();
    foreach ($translation as $item) {
        $messages[$item['translatekey']] = $item['value'];
    }
    //$language = $dispatcher->getParam('language');
    //echo "lenguage".$language."<br>";
开发者ID:andresfranco,项目名称:Phalcontest,代码行数:31,代码来源:services.php

示例9: function

    return $url;
});
$di->setShared('voltService', function ($view, $di) use($config) {
    $volt = new Volt($view, $di);
    $voltOptions = !empty($config->volt) ? $config->volt->toArray() : [];
    $volt->setOptions(array_merge(['compiledPath' => APPLICATION_PATH . '/cache/views/volt/', 'compiledSeparator' => '-'], $voltOptions));
    $compiler = $volt->getCompiler();
    $compiler->addFilter('url_decode', 'urldecode')->addFilter('rawurlencode', 'rawurlencode')->addFilter('round', 'round')->addFilter('count', 'count')->addFunction('number_format', 'number_format')->addFunction('array_slice', 'array_slice')->addFunction('strpos', 'strpos');
    return $volt;
});
$di->setShared('view', function () use($config, $di) {
    $view = new \Phalcon\Mvc\View();
    //WARNING: DO NOT TOUCH EVENTS PRIORITY!!!
    /** @var \Phalcon\Events\Manager $evManager */
    $evManager = $di->getShared('eventsManager');
    $evManager->enablePriorities(true);
    $evManager->attach('view', $di->get('contextPlugin'), 0);
    $view->setViewsDir($config->application->viewsDir)->setLayout('core')->registerEngines(['.volt' => 'voltService'])->setEventsManager($evManager);
    return $view;
});
$di->set('contextPlugin', ['className' => '\\Plugin\\Context', 'calls' => [['method' => 'setRequest', 'arguments' => [['type' => 'service', 'name' => 'request']]], ['method' => 'setResponse', 'arguments' => [['type' => 'service', 'name' => 'response']]]]]);
$di->setShared('cookies', function () {
    $cookies = new Cookies();
    $cookies->useEncryption(false);
    return $cookies;
});
$di['vk'] = function () use($config) {
    $schema = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . '://';
    return new \OAuth\Services\Vkontakte($schema . $_SERVER['HTTP_HOST'] . ($config->vk->callback ?: ''), ['client_id' => $config->vk->id, 'client_secret' => $config->vk->secret]);
};
return $di;
开发者ID:aisuhua,项目名称:vkplay,代码行数:31,代码来源:services.php

示例10: function

/**
 * Custom mail component
 */
$di->set('acl', function () {
    return new Acl();
});
/**
 * Set up the security service
 */
$di->set('security', function () {
    $security = new Security();
    //Set the password hashing factor to 12 rounds
    $security->setWorkFactor(12);
    return $security;
}, true);
/**
 * Set the encryption service
 * Key: 7}T/~"4%[GW*7O-)!"nU
 */
$di->setShared('crypt', function () {
    $crypt = new \Phalcon\Crypt();
    $crypt->setMode(MCRYPT_MODE_CFB);
    $crypt->setKey('7}T/~"4%[GW*7O-)!"nU');
    return $crypt;
});
/**
 * Set global access to config, excluding db settings
 */
$di->set('config', $config);
$di->get('auth');
开发者ID:fenghuilee,项目名称:Talon,代码行数:30,代码来源:services.php

示例11: AdapterPhp

if (file_exists(__DIR__ . '/config.global.php')) {
    $overrideConfig = (include __DIR__ . '/config.global.php');
    $config->merge($overrideConfig);
}
//It crreated when save in admin dashboard
if (file_exists(ROOT_DIR . 'content/options/options.php')) {
    $overrideConfig = new AdapterPhp(ROOT_DIR . 'content/options/options.php');
    $config->merge($overrideConfig);
}
if (file_exists(__DIR__ . '/config.' . APPLICATION_ENV . '.php')) {
    $overrideConfig = (include __DIR__ . '/config.' . APPLICATION_ENV . '.php');
    $config->merge($overrideConfig);
}
$di->set('config', $config, true);
// setup timezone
date_default_timezone_set($di->get('config')->application->timezone ?: 'UTC');
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di->set('url', function () use($di) {
    $url = new UrlResolver();
    $config = $di->get('config');
    if (APPLICATION_ENV == 'production') {
        $url->setStaticBaseUri($config->application->production->staticBaseUri);
    } else {
        $url->setStaticBaseUri($config->application->development->staticBaseUri);
    }
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
开发者ID:SidRoberts,项目名称:phanbook,代码行数:31,代码来源:services.php

示例12: getSharedService

 /**
  * Obtains a service from the DI
  *
  * @param string $serviceName
  * @return object
  */
 public function getSharedService($serviceName)
 {
     $dependencyInjector = null;
     $dependencyInjector = $this->_dependencyInjector;
     if (!is_object($dependencyInjector)) {
         $dependencyInjector = new FactoryDefault();
         $this->_dependencyInjector = $dependencyInjector;
     }
     return $dependencyInjector->get($serviceName);
 }
开发者ID:snowair,项目名称:phalcon-app,代码行数:16,代码来源:Micro.php

示例13: function

//     $url->setBaseUri('/');
//     return $url;
// });
/**
 * This service controls the initialization of models, keeping record of relations
 * between the different models of the application.
 */
$di->set('collectionManager', function () {
    return new Manager();
});
$di->set('modelsManager', function () {
    return new ModelsManager();
});
// Database connection is created based in the parameters defined in the configuration file
$di->set('db', function () use($di) {
    return new Mysql(['host' => $di->get('config')->database->mysql->host, 'username' => $di->get('config')->database->mysql->username, 'password' => $di->get('config')->database->mysql->password, 'dbname' => $di->get('config')->database->mysql->dbname, 'options' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $di->get('config')->database->mysql->charset]]);
}, true);
$di->set('cookies', function () {
    $cookies = new Cookies();
    $cookies->useEncryption(false);
    return $cookies;
}, true);
$di->set('security', function () {
    $security = new Security();
    //Set the password hashing factor to 12 rounds
    $security->setWorkFactor(12);
    return $security;
}, true);
//Set the models cache service
$di->set('modelsCache', function () {
    //Cache data for one day by default
开发者ID:phalcon-id,项目名称:phalcon-api,代码行数:31,代码来源:service.php

示例14: function

        $appender->setLogLevel(Logger::ERROR);
        $logger->push($appender);
    }
    return $logger;
};
$di['db'] = function () use($di, $config) {
    Model::setup(['notNullValidations' => false]);
    $conn = new DbAdapter($config->database->toArray());
    if (isset($config->eventListeners->db)) {
        $em = $di['eventsManager'];
        foreach ($config->eventListeners->db as $listener => $options) {
            if (is_numeric($listener)) {
                $listener = $options;
                $options = null;
            }
            $em->attach('db', $di->get($listener, [$options]));
        }
        $conn->setEventsManager($em);
    }
    return $conn;
};
if (extension_loaded('apcu')) {
    $di['modelsMetadata'] = function () use($config) {
        return new MetadataApc($config->metadata->toArray());
    };
} else {
    $di['modelsMetadata'] = MetadataMemory::CLASS;
}
$di['eventsManager'] = function () use($di, $config) {
    $eventsManager = new EventsManager();
    $di['eventsManager'] = $eventsManager;
开发者ID:wenbinye,项目名称:admin-gen,代码行数:31,代码来源:services.php

示例15: function

}, true);
/**
 * This service controls the initialization of models, keeping record of relations
 * between the different models of the application.
 */
$di->set('collectionManager', function () {
    return new Manager();
});
// Register the flash service with custom CSS classes
$di->set('flashSession', function () {
    $flash = new Session(array('error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info'));
    return $flash;
});
// Database connection is created based in the parameters defined in the configuration file
$di->set('db', function () use($di) {
    return new Mysql(['host' => $di->get('config')->database->host, 'username' => $di->get('config')->database->username, 'password' => $di->get('config')->database->password, 'dbname' => $di->get('config')->database->dbname, 'schema' => $di->get('config')->database->schema, 'options' => array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $di->get('config')->database->charset)]);
}, true);
$di->set('cookies', function () {
    $cookies = new Cookies();
    return $cookies;
}, true);
$di->set('crypt', function () use($di) {
    $crypt = new Crypt();
    $crypt->setKey($di->get('config')->application->cryptSalt);
    //Use your own key!
    return $crypt;
});
$di->set('security', function () {
    $security = new Security();
    //Set the password hashing factor to 12 rounds
    $security->setWorkFactor(12);
开发者ID:vikilaboy,项目名称:digitalkrikits,代码行数:31,代码来源:services.php


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