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


PHP Container::get方法代码示例

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


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

示例1: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  void
  */
 public function register(Container $container)
 {
     $closure = function (Container $container) {
         return new \S3($container->get('app')->get('amazon.access_key'), $container->get('app')->get('amazon.secret_key'));
     };
     Ioc::getContainer()->share('s3', $closure);
 }
开发者ID:Trult,项目名称:windspeaker-demo,代码行数:14,代码来源:S3Provider.php

示例2: createInfoBox

 /**
  * createInfoBox
  *
  * @param Container  $container
  * @param \stdClass  $article
  * @param mixed      $params
  *
  * @return  string
  */
 public static function createInfoBox(Container $container, $article, $params = null)
 {
     // Include Component Core
     $param = ExtensionHelper::getParams('com_userxtd');
     $doc = \JFactory::getDocument();
     $app = $container->get('app');
     LanguageHelper::loadLanguage('com_userxtd', 'admin');
     // init params
     $image_field = $param->get('UserInfo_ImageField', 'BASIC_AVATAR');
     $website_field = $param->get('UserInfo_WebiteField', 'BASIC_WEBSITE');
     $include_css = $param->get('UserInfo_IncludeCSS_Article', 1);
     // Image params
     $width = $param->get('UserInfo_ImageWidth', 150);
     $height = $param->get('UserInfo_ImageHeight', 150);
     $crop = $param->get('UserInfo_ImageCrop', 1) ? \JImage::CROP_RESIZE : false;
     // Include CSS
     if ($include_css) {
         /** @var $asset \Windwalker\Helper\AssetHelper */
         $asset = $container->get('helper.asset');
         $asset->addCss('userxtd-userinfo.css', 'com_userxtd');
     }
     $user = \UXFactory::getUser($article->created_by);
     // Images
     $image = $user->get($image_field);
     $thumb = new Thumb(null, 'com_userxtd');
     $image = $thumb->resize($image, $width, $height, $crop);
     // Link
     $query = array('option' => 'com_users', 'view' => 'profile', 'id' => $user->get('id'));
     $link = \JRoute::_('index.php?' . http_build_query($query));
     //Route::_('com_userxtd.user_id', array('id' => $user->get('id')));
     // Website
     $website_link = $user->get($website_field);
     // Render
     return with(new FileLayout('userxtd.content.userinfo', null, array('component' => 'com_userxtd')))->render(array('params' => $param, 'article' => $article, 'link' => $link, 'website_link' => $website_link, 'image' => $image, 'user' => $user));
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:44,代码来源:UserInfo.php

示例3: create

 /**
  * create
  *
  * @param string $storage
  *
  * @return  ImageUploaderManager
  */
 public function create($storage = null)
 {
     $config = $this->container->get('config');
     $storage = $storage ?: $config->get('unidev.image.storage');
     if (!$storage) {
         throw new \DomainException('No image storage provider.');
     }
     if (is_string($storage)) {
         $class = __NAMESPACE__ . '\\Storage\\' . ucfirst($storage) . 'ImageStorage';
         $storage = new $class($this->container->get('unidev.storage.' . strtolower($storage)), $config->extract('unidev.' . $storage));
     }
     return new ImageUploaderManager($storage);
 }
开发者ID:lyrasoft,项目名称:unidev,代码行数:20,代码来源:ImageUploaderFactory.php

示例4: addFieldJs

 /**
  * Add JS to head.
  *
  * @return  void
  */
 public function addFieldJs()
 {
     JHtmlBehavior::framework(true);
     $asset = $this->container->get('helper.asset');
     $input = $this->container->get('input');
     $asset->addJS('cck/fields.js', $input->get('option'));
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:12,代码来源:fields.php

示例5: register

 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container $container The DI container.
  *
  * @return  Container  Returns itself to support chaining.
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     $ioClass = 'Phoenix\\IO\\IO';
     $container->alias('io', $ioClass)->alias('Muse\\IO\\IO', $ioClass)->alias('Muse\\IO\\IOInterface', $ioClass)->share($ioClass, new IO($this->controller->getCommand()));
     $container->alias('operator.copy', 'Phoenix\\Generaotr\\FileOperator\\CopyOperator')->createObject('Phoenix\\Generaotr\\FileOperator\\CopyOperator');
     $closure = function (Container $container) {
         return new OperatorFactory($container->get('io'), $this->controller->getTagVariables());
     };
     $container->share('operator.factory', $closure);
 }
开发者ID:ventoviro,项目名称:phoenix,代码行数:19,代码来源:MuseProvider.php

示例6: setFieldData

 /**
  * If default value exists.
  */
 public function setFieldData()
 {
     $input = $this->container->get('input');
     if (!$input->get('id')) {
         $app = JFactory::getApplication();
         $app->setUserState('lib_windwalker.cck.fields', null);
     }
     $type = $input->get('field_type');
     $this->value = $type ?: $this->value;
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:13,代码来源:fieldtype.php

示例7: prepareTemplate

 /**
  * Prepare the template.
  *
  * @param string $template Template name.
  *
  * @return  void
  */
 protected function prepareTemplate($template)
 {
     if ($this->templatePrepared) {
         return;
     }
     // Load the language file for the template
     $lang = $this->container->get('language');
     $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, false) || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", $lang->getDefault(), false, false);
     $this->templatePrepared = true;
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:17,代码来源:AbstractEngine.php

示例8: cleanCache

 /**
  * Clean the cache
  *
  * @param   string   $group      The cache group
  * @param   integer  $client_id  The ID of the client
  *
  * @return  void
  */
 protected function cleanCache($group = null, $client_id = 0)
 {
     $conf = $this->container->get('joomla.config');
     $dispatcher = $this->container->get('event.dispatcher');
     $input = $this->container->get('input');
     $options = array('defaultgroup' => $group ? $group : (isset($this->option) ? $this->option : $input->get('option')), 'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'));
     $cache = \JCache::getInstance('callback', $options);
     $cache->clean();
     // Trigger the onContentCleanCache event.
     $dispatcher->trigger($this->eventCleanCache, $options);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:19,代码来源:Model.php

示例9: addScript

    /**
     * Add JS to head.
     */
    public function addScript($num = 0)
    {
        $script = <<<SCRIPT
;jQuery(document).ready(function(\$)
{
\twindow.WindwalkerCCKList.init({});
});
SCRIPT;
        $asset = $this->container->get('helper.asset');
        $asset->addJs('cck/list.js');
        $asset->internalJS($script);
    }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:15,代码来源:options.php

示例10: createComponent

 /**
  * createComponent
  *
  * @param array $input
  *
  * @return  StubComponent
  */
 protected function createComponent($input = array())
 {
     if (!$input instanceof \JInput) {
         $input = new \JInput($input);
     }
     $container = new Container();
     $container->registerServiceProvider(new SystemProvider());
     $container->share('input', $input);
     $config = array('init' => array('path' => array('self' => __DIR__ . '/StubAdmin', 'site' => __DIR__ . '/StubSite', 'administrator' => __DIR__ . '/StubAdmin'), 'constants' => false));
     $container->share('com_stub.config', new Registry($config));
     \JLoader::registerPrefix('Stub', __DIR__ . '/StubAdmin');
     return new StubComponent('stub', $input, $container->get('app'), $container);
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:20,代码来源:RealComponentTest.php

示例11: testDump

 /**
  * testDump
  *
  * @covers \Windwalker\DI\Container::dump()
  */
 public function testDump()
 {
     // Not shared
     $this->instance->set('foo', function () {
         return new \ArrayObject();
     }, false, false);
     $this->instance->get('foo');
     $dumpResult = $this->instance->dump();
     $this->assertEquals(0, count($dumpResult['data']));
     // Shared
     $this->instance->set('bar', function () {
         return new \ArrayObject();
     }, true, false);
     $this->instance->get('bar');
     $dumpResult = $this->instance->dump();
     $this->assertEquals(1, count($dumpResult['data']));
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:22,代码来源:ContainerTest.php

示例12: registerBundles

 /**
  * Register Bundles
  *
  * @param Container $container DI container.
  *
  * @return  void
  */
 protected function registerBundles(Container $container)
 {
     if (!is_dir(WINDWALKER_BUNDLE)) {
         return;
     }
     $paths = new PathCollection(array(WINDWALKER . '/bundles', WINDWALKER_BUNDLE));
     $bundles = $paths->find('Bundle$');
     $config = $container->get('windwalker.config');
     foreach ($bundles as $bundle) {
         $bundleName = $bundle->getBasename();
         $class = $bundleName . '\\' . $bundleName;
         \JLoader::registerNamespace($bundleName, dirname((string) $bundle));
         if (class_exists($class) && is_subclass_of($class, 'Windwalker\\Bundle\\AbstractBundle')) {
             $config->set('bundle.' . $bundleName, $class);
             $class::registerProvider($container);
         }
     }
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:25,代码来源:Windwalker.php

示例13: testRegisterServiceProvider

 /**
  * Method to test registerServiceProvider().
  *
  * @return void
  *
  * @covers Windwalker\DI\Container::registerServiceProvider
  */
 public function testRegisterServiceProvider()
 {
     $this->instance->registerServiceProvider(new StubServiceProvider());
     $this->assertEquals('Bingo', $this->instance->get('bingo'));
 }
开发者ID:rokite,项目名称:windwalker,代码行数:12,代码来源:ContainerTest.php

示例14: buildElement

 /**
  * Convert a element data to JForm XML field string.
  *
  * @param    string $field_type Type of this field.
  * @param    array  $attrs      Field's attributes.
  * @param    array  $option     Some option.
  *
  * @return  string  Field XML element.
  */
 public function buildElement($field_type = 'text', $attrs = null, $option = array())
 {
     $node_name = !empty($option['node_name']) ? $option['node_name'] : 'field';
     $field_type = $field_type ? $field_type : 'text';
     $input = $this->container->get('input');
     $attrs = $this->convertJsonToArray($attrs);
     if (!is_array($attrs)) {
         $attrs = $input->getVar('attrs', array());
     }
     $this->event->trigger('onCCKEngineBeforeBuildElement', array(\JArrayHelper::getValue($option, 'context'), &$field_type, &$attrs, $option));
     if (!is_array($attrs)) {
         return '<' . $node_name . '/>';
     }
     // Rebuild options
     // ================================================================
     if (isset($attrs['options'])) {
         $attrs['options'] = ArrayHelper::pivotBySort($attrs['options']);
     }
     $element = '';
     $options = array();
     // Build Field Attrs
     // ================================================================
     // set type in attrs
     $attrs['type'] = $field_type;
     // set default
     if (is_array(\JArrayHelper::getValue($attrs, 'default'))) {
         $attrs['default'] = implode(',', $attrs['default']);
     }
     // start buliding attrs and options
     foreach ($attrs as $key => $attr) {
         if ($key == 'options' && is_array($attr)) {
             // Bulid options
             foreach ($attr as $key => $opt) {
                 if (!trim($opt['value'])) {
                     continue;
                 }
                 $value = addslashes(trim($opt['value']));
                 $text = htmlspecialchars(addslashes(trim($opt['text'])));
                 $options[] = "\t<option value=\"{$value}\">{$text}</option>\n";
             }
         } else {
             // Build attributes
             if (!trim($attr)) {
                 continue;
             }
             $attr = trim($attr);
             $attr = htmlspecialchars(addslashes($attr));
             $element .= "\t{$key}=\"{$attr}\"\n";
         }
     }
     // Build Element
     // ================================================================
     if (count($options) < 0) {
         $element = "<{$node_name}\n{$element}/>";
     } else {
         $options = implode('', $options);
         $element = "<{$node_name}\n{$element}>\n{$options}</{$node_name}>";
     }
     $this->event->trigger('onCCKEngineAfterBuildElement', array(\JArrayHelper::getValue($option, 'context'), &$field_type, &$element, $option));
     return $element;
 }
开发者ID:ForAEdesWeb,项目名称:AEW3,代码行数:70,代码来源:CCKEngine.php


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