Пример #1
0
 /**
  * Locate the addon containing an object.
  * Returns the addon's dot namespace.
  *
  * @param $object
  * @return null|string
  */
 public function locate($object)
 {
     if (!is_object($object)) {
         return null;
     }
     $class = explode('\\', get_class($object));
     $vendor = snake_case(array_shift($class));
     $addon = snake_case(array_shift($class));
     foreach ($this->config->get('streams::addons.types') as $type) {
         if (ends_with($addon, $type)) {
             $addon = str_replace('_' . $type, '', $addon);
             $namespace = "{$vendor}.{$type}.{$addon}";
             return $this->addons->has($namespace) ? $namespace : null;
         }
     }
     return null;
 }