Example #1
0
 /**
  * Tests for the Fqn::tail method.
  *
  * @return void
  * @covers Database\Utility\CodeLogic\Fqn::tail
  */
 public function testTail()
 {
     // No namespace
     $this->assertEquals('Foo', Fqn::tail('Foo'));
     // A namespace
     $this->assertEquals('Baz', Fqn::tail('Foo\\Bar\\Baz'));
 }
Example #2
0
 /**
  * Returns the cache key (prefix) to be used with a table class.
  *
  * @param \Cake\ORM\Table $table The table class
  * @return string
  */
 public static function table(\Cake\ORM\Table $table)
 {
     $alias = get_class($table);
     if (false === isset(static::$liveCache[__FUNCTION__][$alias])) {
         static::$liveCache[__FUNCTION__][$alias] = implode('_', array_filter([Inflector::underscore($table->connection()->configName()), Fqn::prefix($alias), Inflector::underscore(Fqn::root($alias)), Inflector::underscore(Fqn::tail($alias)), Inflector::underscore($table->alias())]));
     }
     return static::$liveCache[__FUNCTION__][$alias];
 }
Example #3
0
 /**
  * Returns the configure key prefix to be used with any class.
  * It consists of a suffix ("plugin" if the namesapce is not App or Cake),
  * the namespace and the class name, separated by dots.
  *
  * Examples
  * - \App\View\Helper\ResultsHelper would give App.ResultsHelper
  * - \Cake\View\Helper\HtmlHelper would give Cake.HtmlHelper
  * - \Database\Model\Behavior\FormattableBehavior would give plugin.Database.FormattableBehavior
  *
  * @param Oject $class The class whose configure prefix is needed
  * @return string
  */
 public static function fqn($class)
 {
     $alias = get_class($class);
     if (false === isset(static::$liveCache[__FUNCTION__][$alias])) {
         $root = Fqn::root($alias);
         static::$liveCache[__FUNCTION__][$alias] = implode('.', array_filter([Fqn::prefix($alias), $root, Fqn::tail($alias)]));
     }
     return static::$liveCache[__FUNCTION__][$alias];
 }