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


PHP DI\Container类代码示例

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


在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testCreateConsole

 /**
  * Method to test createConsole().
  *
  * @return void
  *
  * @covers Windwalker\Provider\CliProvider::createConsole
  */
 public function testCreateConsole()
 {
     $container = new Container();
     $provider = new CliProvider();
     $container->share('windwalker.config', new Registry(array('bundle' => array())));
     $container->share('io', new IO());
     $this->assertInstanceOf('Windwalker\\Console\\Application\\Console', $provider->createConsole($container));
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:15,代码来源:CliProviderTest.php

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

示例5:

 /**
  * StubContainer constructor
  *
  * @param Container $parent
  */
 function __construct(Container $parent = null)
 {
     parent::__construct($parent);
     // Add fake root $instance and children
     self::$instance = new \ArrayObject();
     self::$children['foo'] = new \ArrayObject();
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:12,代码来源:StubContainer.php

示例6: refreshIncludePaths

 /**
  * Refresh the list of include paths
  *
  * @return  void
  */
 protected function refreshIncludePaths()
 {
     $app = Container::getInstance()->get('app');
     // Reset includePaths
     $this->includePaths = array();
     // (1 - lower priority) Frontend base layouts
     $this->addIncludePaths(JPATH_ROOT . '/layouts');
     // (2) Windwalker layouts.
     $this->addIncludePaths(WINDWALKER . '/resource/layouts');
     // (3) Standard Joomla! template override
     $this->addIncludePaths(JPATH_THEMES . '/' . $app->getTemplate() . '/html/layouts');
     // Component layouts & overrides if exist
     $component = $this->options->get('component', null);
     if (!empty($component)) {
         // (4) Component path
         if ($this->options->get('client') == 0) {
             $this->addIncludePaths(JPATH_SITE . '/components/' . $component . '/layouts');
         } else {
             $this->addIncludePaths(JPATH_ADMINISTRATOR . '/components/' . $component . '/layouts');
         }
         // (5) Component template overrides path
         $this->addIncludePath(JPATH_THEMES . '/' . $app->getTemplate() . '/html/layouts/' . $component);
     }
     // (6 - highest priority) Received a custom high priority path ?
     if (!is_null($this->basePath)) {
         $this->addIncludePath(rtrim($this->basePath, DIRECTORY_SEPARATOR));
     }
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:33,代码来源:FileLayout.php

示例7: getContainer

 /**
  * Get the DI container.
  *
  * @return  Container
  *
  * @since   1.0
  *
  * @throws  \UnexpectedValueException May be thrown if the container has not been set.
  */
 public function getContainer()
 {
     if (!$this->container) {
         $this->container = Container::getInstance($this->getName());
     }
     return $this->container;
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:16,代码来源:AbstractBundle.php

示例8: render

 /**
  * Render the profiler log data, and echo it..
  *
  * @param   string   $namespace The JProfiler instance ID. Default is the core profiler "Application".
  * @param   boolean  $asString  Return as string.
  *
  * @return  string
  */
 public static function render($namespace = 'Windwalker', $asString = false)
 {
     $app = Container::getInstance()->get('app');
     if ($namespace == 'core' || !$namespace) {
         $namespace = 'Application';
     }
     $buffer = 'No Profiler data.';
     if (isset(self::$profiler[$namespace])) {
         $_PROFILER = self::$profiler[$namespace];
         $buffer = $_PROFILER->getBuffer();
         $buffer = implode("\n<br />\n", $buffer);
     } else {
         $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace);
         $buffer = $buffer ? implode("\n<br />\n", $buffer) : '';
     }
     $buffer = $buffer ? $buffer : 'No Profiler data.';
     // Get last page logs
     $state_buffer = \JArrayHelper::getValue(self::$stateBuffer, $namespace);
     if ($state_buffer) {
         $state_buffer = implode("\n<br />\n", $state_buffer);
         $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer;
     }
     // Render
     $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>';
     $app->setUserState('windwalker.system.profiler.' . $namespace, '');
     if ($asString) {
         return $buffer;
     }
     echo $buffer;
     return '';
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:39,代码来源:ProfilerHelper.php

示例9: quickadd

    /**
     * Add an quick add button & modal
     *
     * @return string The quickadd button.
     */
    public function quickadd()
    {
        // Prepare Element
        $readonly = $this->getElement('readonly', false);
        $disabled = $this->getElement('disabled', false);
        if ($readonly || $disabled) {
            return '';
        }
        $container = Container::getInstance();
        $input = $container->get('input');
        $quickadd = $this->getElement('quickadd', false);
        $table_name = $this->getElement('table', '#__' . $this->component . '_' . $this->view_list);
        $key_field = $this->getElement('key_field', 'id');
        $value_field = $this->getElement('value_field', 'title');
        $formpath = WINDWALKER_SOURCE . "/Form/Forms/quickadd/category.xml";
        $quickadd_handler = $this->getElement('quickadd_handler', $input->get('option'));
        $title = $this->getElement('quickadd_label', 'LIB_WINDWALKER_QUICKADD_TITLE');
        $qid = $this->id . '_quickadd';
        if (!$quickadd) {
            return '';
        }
        // Prepare Script & Styles
        /** @var Windwalker\Helper\AssetHelper $asset */
        $asset = Container::getInstance($quickadd_handler)->get('helper.asset');
        $asset->addJs('js/quickadd.js');
        // Set AKQuickAddOption
        $config['task'] = $this->view_item . '.ajax.legacyquickadd';
        $config['quickadd_handler'] = $quickadd_handler;
        $config['cat_extension'] = (string) $this->element['extension'];
        $config['extension'] = 'com_' . $this->component;
        $config['component'] = $this->component;
        $config['table'] = $table_name;
        $config['model_name'] = 'category';
        $config['key_field'] = $key_field;
        $config['value_field'] = $value_field;
        $config['joomla3'] = JVERSION >= 3;
        $config = HtmlHelper::getJSObject($config);
        $script = <<<QA
        window.addEvent('domready', function(){
            var AKQuickAddOption = {$config} ;
            AKQuickAdd.init('{$qid}', AKQuickAddOption);
        });
QA;
        $asset->internalJS($script);
        // Load Language & Form
        LanguageHelper::loadLanguage('com_' . $this->component, null);
        $formpath = str_replace(JPATH_ROOT, '', $formpath);
        $content = ModalHelper::getQuickaddForm($qid, $formpath, (string) $this->element['extension']);
        // Prepare HTML
        $html = '';
        $button_title = $title;
        $modal_title = $button_title;
        $button_class = 'btn btn-small btn-success delicious green light fltlft quickadd_button';
        $footer = "<button class=\"btn delicious\" type=\"button\" onclick=\"\$\$('#{$qid} input', '#{$qid} select').set('value', '');AKQuickAdd.closeModal('{$qid}');\" data-dismiss=\"modal\">" . JText::_('JCANCEL') . "</button>";
        $footer .= "<button class=\"btn btn-primary delicious blue\" type=\"submit\" onclick=\"AKQuickAdd.submit('{$qid}', event);\">" . JText::_('JSUBMIT') . "</button>";
        $html .= ModalHelper::modalLink(JText::_($button_title), $qid, array('class' => $button_class, 'icon' => 'icon-new icon-white'));
        $html .= ModalHelper::renderModal($qid, $content, array('title' => JText::_($modal_title), 'footer' => $footer));
        return $html;
    }
开发者ID:beingsane,项目名称:quickcontent,代码行数:64,代码来源:categoryadd.php

示例10: setup

 /**
  * Method to attach a JForm object to the field.
  *  Catch upload files when form setup.
  *
  * @param   SimpleXMLElement $element  The JXmlElement object representing the <field /> tag for the form field object.
  * @param   mixed            $value    The form field value to validate.
  * @param   string           $group    The field name group control value. This acts as as an array container for the field.
  *                                     For example if the field has name="foo" and the group value is set to "bar" then the
  *                                     full field name would end up being "bar[foo]".
  *
  * @return  boolean  True on success.
  */
 public function setup(SimpleXMLElement $element, $value, $group = null)
 {
     parent::setup($element, $value, $group);
     $container = \Windwalker\DI\Container::getInstance();
     $input = $container->get('input');
     $delete = isset($_REQUEST['jform']['profile'][$this->element['name'] . '_delete']) ? $_REQUEST['jform']['profile'][$this->element['name'] . '_delete'] : 0;
     if ($delete == 1) {
         $this->value = '';
     } else {
         // Upload Image
         // ===============================================
         if (isset($_FILES['jform']['name']['profile'])) {
             foreach ($_FILES['jform']['name']['profile'] as $key => $var) {
                 if (!$var) {
                     continue;
                 }
                 // Get Field Attr
                 $width = $this->element['save_width'] ? $this->element['save_width'] : 800;
                 $height = $this->element['save_height'] ? $this->element['save_height'] : 800;
                 // Build File name
                 $src = $_FILES['jform']['tmp_name']['profile'][$key];
                 $var = explode('.', $var);
                 $date = DateHelper::getDate();
                 $name = md5((string) $date . $width . $height . $src) . '.' . array_pop($var);
                 $url = "images/cck/{$date->year}/{$date->month}/{$date->day}/" . $name;
                 // A Event for extend.
                 $container->get('event.dispatcher')->trigger('onCCKEngineUploadImage', array(&$url, &$this, &$this->element));
                 $dest = JPATH_ROOT . '/' . $url;
                 // Upload First
                 JFile::upload($src, $dest);
                 // Resize image
                 $img = new JImage();
                 $img->loadFile(JPATH_ROOT . '/' . $url);
                 $img = $img->resize($width, $height);
                 switch (array_pop($var)) {
                     case 'gif':
                         $type = IMAGETYPE_GIF;
                         break;
                     case 'png':
                         $type = IMAGETYPE_PNG;
                         break;
                     default:
                         $type = IMAGETYPE_JPEG;
                         break;
                 }
                 // Save
                 $img->toFile($dest, $type, array('quality' => 85));
                 // Set in Value
                 $this->value = $url;
                 // Clean cache
                 $thumb = $this->getThumbPath();
                 if (is_file(JPATH_ROOT . '/' . $thumb)) {
                     \JFile::delete(JPATH_ROOT . '/' . $thumb);
                 }
             }
         }
     }
     return true;
 }
开发者ID:ForAEdesWeb,项目名称:AEW13,代码行数:71,代码来源:uploadimage.php

示例11: getDate

 /**
  * Return the {@link JDate} object
  *
  * @param   mixed  $time      The initial time for the JDate object
  * @param   mixed  $tzOffset  The timezone offset.
  *
  * @return  \JDate object
  */
 public static function getDate($time = 'now', $tzOffset = null)
 {
     if (!$tzOffset) {
         $config = Container::getInstance()->get('joomla.config');
         $tzOffset = $config->get('offset');
     }
     return \JFactory::getDate($time, $tzOffset);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:16,代码来源:DateHelper.php

示例12: restoreApplication

 /**
  * Restore original Application instance
  *
  * @return  void
  */
 public static function restoreApplication()
 {
     $container = Container::getInstance();
     $className = get_class(static::$originalApplication);
     $container->alias('app', $className);
     $container->share($className, static::$originalApplication);
     \JFactory::$application = static::$originalApplication;
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:13,代码来源:TestContainerHelper.php

示例13: publishingPeriod

 /**
  * Get a query string to filter the publishing items now.
  *
  * Will return: '( publish_up < 'xxxx-xx-xx' OR publish_up = '0000-00-00' )
  *   AND ( publish_down > 'xxxx-xx-xx' OR publish_down = '0000-00-00' )'
  *
  * @param   string $prefix Prefix to columns name, eg: 'a.' will use `a`.`publish_up`.
  *
  * @return  string Query string.
  */
 public static function publishingPeriod($prefix = '')
 {
     $db = Container::getInstance()->get('db');
     $nowDate = $date = DateHelper::getDate()->toSQL();
     $nullDate = $db->getNullDate();
     $date_where = " ( {$prefix}publish_up < '{$nowDate}' OR  {$prefix}publish_up = '{$nullDate}') AND " . " ( {$prefix}publish_down > '{$nowDate}' OR  {$prefix}publish_down = '{$nullDate}') ";
     return $date_where;
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:18,代码来源:QueryHelper.php

示例14: getInput

    /**
     * Method to get the user field input markup.
     *
     * @return  string  The field input markup.
     */
    protected function getInput()
    {
        $html = array();
        $groups = $this->getGroups();
        $excluded = $this->getExcluded();
        $link = 'index.php?option=com_users&amp;view=users&amp;layout=modal&amp;tmpl=component&amp;field=' . $this->id . (isset($groups) ? '&amp;groups=' . base64_encode(json_encode($groups)) : '') . (isset($excluded) ? '&amp;excluded=' . base64_encode(json_encode($excluded)) : '');
        // Initialize some field attributes.
        $attr = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
        $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
        // Initialize JavaScript field attributes.
        $onchange = (string) $this->element['onchange'];
        // Load the modal behavior script.
        WindwalkerScript::modal('.hasUserModal');
        JQueryScript::ui(array('effect'));
        // Build the script.
        $js = <<<JS
function jSelectUser_{$this->id}(id, title) {
\tvar input = jQuery('#{$this->id}_id');
\tvar oldId = input.val();

\tif (oldId != id) {
\t\tinput.val(id);
\t\tjQuery('#{$this->id}_name').val(title).removeClass('invalid').delay(300).effect('highlight');
\t}

\t{$onchange};

\tWindwalker.Modal.hide();
};
JS;
        // Add the script to the document head.
        $asset = Container::getInstance()->get('helper.asset');
        $asset->internalJS($js);
        // Load the current username if available.
        $table = JTable::getInstance('user');
        if ($this->value) {
            $table->load($this->value);
        } elseif (strtoupper($this->value) == 'CURRENT') {
            // 'CURRENT' is not a reasonable value to be placed in the html
            $this->value = JFactory::getUser()->id;
            $table->load($this->value);
        } else {
            $table->name = JText::_('JLIB_FORM_SELECT_USER');
        }
        // Create a dummy text field with the user name.
        $html[] = '<div class="input-append">';
        $html[] = '	<input type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($table->name, ENT_COMPAT, 'UTF-8') . '"' . ' readonly' . $attr . ' />';
        // Create the user select button.
        if (!XmlHelper::getBool($this->element, 'readonly', false)) {
            $html[] = '		<a class="btn btn-primary hasUserModal modal_' . $this->id . '" title="' . JText::_('JLIB_FORM_CHANGE_USER') . '" href="' . $link . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">';
            $html[] = '<i class="icon-user"></i></a>';
        }
        $html[] = '</div>';
        // Create the real field, hidden, that stored the user id.
        $html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $this->value . '" />';
        return implode("\n", $html);
    }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:62,代码来源:winduser.php

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


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