emerap / il18_config

缓存接口,用于集成到第三方库

dev-master 2016-10-29 14:52 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:53:09 UTC


README

创建类并扩展自 \Emerap\Il18Config。

use \Emerap\Il18Config\Il18Config;

class ClassName extends Il18Config {

  /**
     * {@inheritdoc}
     */
    public static function getLibraryId() {
      return 'library_id';
    }
  
    /**
     * {@inheritdoc}
     */
    public static function getServicesJson() {
      return __DIR__ . '/services.yml';
    }
  
    /**
     * Get cache instance.
     *
     * @return Service
     *   Service instance.
     */
    public function cache() {
      return self::getService('service_id');
    }
} 

创建类实现 \Emerap\Il18Config\Il18ConfigInterface 并使用 trait \Emerap\Il18Config\Il18ConfigTrait。

use Emerap\Il18Config\Il18ConfigInterface;
use Emerap\Il18Config\Il18ConfigTrait;

class ClassName implements Il18ConfigInterface {

  use Il18ConfigTrait;
  
  /**
     * {@inheritdoc}
     */
    public static function getLibraryId() {
      return 'library_id';
    }
  
    /**
     * {@inheritdoc}
     */
    public static function getServicesJson() {
      return __DIR__ . '/services.yml';
    }
  
    /**
     * Get cache instance.
     *
     * @return Service
     *   Service instance.
     */
    public function cache() {
      return self::getService('service_id');
    }
} 

版权所有 © 2016 [ Pokhodyun Alexander]