Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/vendors/Txp.php - 69 lines - 1640 bytes - Summary - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * http://textpattern.com
   6   *
   7   * Copyright (C) 2016 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
  22   */
  23  
  24  /**
  25   * Factory.
  26   *
  27   * <code>
  28   * Txp::get('\Textpattern\Password\Hash')->hash('abc');
  29   * Txp::get('\Textpattern\Type\StringType', 'Hello word!')->replace('!', '.')->getLength();
  30   * </code>
  31   *
  32   * @since   4.6.0
  33   * @package Container
  34   */
  35  
  36  class Txp implements \Textpattern\Container\FactoryInterface
  37  {
  38      /**
  39       * Stores the container instance.
  40       *
  41       * @var \Textpattern\Container\Container
  42       */
  43  
  44      private static $container;
  45  
  46      /**
  47       * {@inheritdoc}
  48       */
  49  
  50      public static function get($name)
  51      {
  52          $args = func_get_args();
  53  
  54          return self::getContainer()->getInstance(array_shift($args), $args);
  55      }
  56  
  57      /**
  58       * {@inheritdoc}
  59       */
  60  
  61      public static function getContainer()
  62      {
  63          if (!self::$container) {
  64              self::$container = new \Textpattern\Container\Container();
  65          }
  66  
  67          return self::$container;
  68      }
  69  }

title

Description

title

Description

title

Description

title

title

Body