[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/src/ProxyManager/Factory/RemoteObject/Adapter/ -> BaseAdapter.php (source)

   1  <?php
   2  /*
   3   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   4   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   5   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   6   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   7   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   8   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   9   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14   *
  15   * This software consists of voluntary contributions made by many individuals
  16   * and is licensed under the MIT license.
  17   */
  18  
  19  namespace ProxyManager\Factory\RemoteObject\Adapter;
  20  
  21  use ProxyManager\Factory\RemoteObject\AdapterInterface;
  22  use Zend\Server\Client;
  23  
  24  /**
  25   * Remote Object base adapter
  26   *
  27   * @author Vincent Blanchon <blanchon.vincent@gmail.com>
  28   * @license MIT
  29   */
  30  abstract class BaseAdapter implements AdapterInterface
  31  {
  32      /**
  33       * Adapter client
  34       *
  35       * @var \Zend\Server\Client
  36       */
  37      protected $client;
  38  
  39      /**
  40       * Service name mapping
  41       *
  42       * @var string[]
  43       */
  44      protected $map = array();
  45  
  46      /**
  47       * Constructor
  48       *
  49       * @param Client $client
  50       * @param array  $map    map of service names to their aliases
  51       */
  52      public function __construct(Client $client, array $map = array())
  53      {
  54          $this->client = $client;
  55          $this->map    = $map;
  56      }
  57  
  58      /**
  59       * {@inheritDoc}
  60       */
  61      public function call($wrappedClass, $method, array $params = array())
  62      {
  63          $serviceName = $this->getServiceName($wrappedClass, $method);
  64  
  65          if (isset($this->map[$serviceName])) {
  66              $serviceName = $this->map[$serviceName];
  67          }
  68  
  69          return $this->client->call($serviceName, $params);
  70      }
  71  
  72      /**
  73       * Get the service name will be used by the adapter
  74       *
  75       * @param string $wrappedClass
  76       * @param string $method
  77       *
  78       * @return string Service name
  79       */
  80      abstract protected function getServiceName($wrappedClass, $method);
  81  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1