Example #1
0
 /**
  * Load system overrides.
  *
  * @param  array $lines
  * @param        $locale
  * @param        $group
  * @param        $namespace
  * @return array
  */
 protected function loadApplicationOverrides(array $lines, $locale, $group, $namespace)
 {
     if ($namespace == 'streams') {
         $file = $this->application->getResourcesPath("streams/lang/{$locale}/{$group}.php");
         if ($this->files->exists($file)) {
             $lines = array_replace_recursive($lines, $this->files->getRequire($file));
         }
     }
     if (str_is('*.*.*', $namespace)) {
         list($vendor, $type, $slug) = explode('.', $namespace);
         $file = $this->application->getResourcesPath("addons/{$vendor}/{$slug}-{$type}/lang/{$locale}/{$group}.php");
         if ($this->files->exists($file)) {
             $lines = array_replace_recursive($lines, $this->files->getRequire($file));
         }
     }
     return $lines;
 }
 /**
  * Handle the command.
  *
  * @param Application $application
  */
 public function handle(Application $application)
 {
     if (file_exists($routes = base_path('resources/streams/routes.php'))) {
         include $routes;
     }
     if (file_exists($routes = $application->getResourcesPath('routes.php'))) {
         include $routes;
     }
 }
 /**
  * Handle the command.
  *
  * @param Configurator $configurator
  * @param Application  $application
  */
 public function handle(Configurator $configurator, Application $application)
 {
     // Load package configuration.
     $configurator->addNamespace('streams', realpath(__DIR__ . '/../../../resources/config'));
     // Load application overrides.
     $configurator->addNamespaceOverrides('streams', $application->getResourcesPath('streams/config'));
     // Load system overrides.
     $configurator->addNamespaceOverrides('streams', base_path('resources/streams/config'));
 }
 /**
  * Handle the command.
  *
  * @param  Filesystem  $filesystem
  * @param  Application $application
  * @return string
  */
 public function handle(Filesystem $filesystem, Application $application)
 {
     $destination = $application->getResourcesPath('streams/lang');
     if (is_dir($destination) && !$this->command->option('force')) {
         return $this->command->error("{$destination} already exists.");
     }
     $filesystem->copyDirectory(__DIR__ . '/../../../../resources/lang', $destination);
     $this->command->info("Published {$destination}");
 }
 /**
  * Handle the command.
  *
  * @param  Filesystem  $filesystem
  * @param  Application $application
  * @return string
  */
 public function handle(Filesystem $filesystem, Application $application)
 {
     $destination = $application->getResourcesPath('addons/' . $this->addon->getVendor() . '/' . $this->addon->getSlug() . '-' . $this->addon->getType() . '/views');
     if (is_dir($destination) && !$this->command->option('force')) {
         $this->command->error("{$destination} already exists.");
         return;
     }
     $filesystem->copyDirectory($this->addon->getPath('resources/views'), $destination);
     $this->command->info("Published {$destination}");
 }
 /**
  * Handle the command.
  *
  * @param Application $application
  * @param Factory $views
  */
 public function handle(Application $application, Factory $views)
 {
     $views->composer('*', 'Anomaly\\Streams\\Platform\\View\\ViewComposer');
     $views->addNamespace('streams', __DIR__ . '/../../../resources/views');
     $views->addNamespace('resources', base_path('resources/views'));
     $views->addNamespace('storage', $application->getStoragePath());
     $views->addNamespace('app', $application->getResourcesPath());
     $views->addNamespace('root', base_path());
     $views->addExtension('html', 'php');
 }
 /**
  * Handle the command.
  *
  * @param Application $application
  */
 public function handle(Application $application)
 {
     if (!is_file($file = $application->getResourcesPath('.env'))) {
         return;
     }
     foreach (file($file, FILE_IGNORE_NEW_LINES) as $line) {
         // Check for # comments.
         if (!starts_with($line, '#')) {
             putenv($line);
         }
     }
 }
 /**
  * Handle the command.
  *
  * @param  Filesystem  $filesystem
  * @param  Application $application
  * @return string
  */
 public function handle(Filesystem $filesystem, Application $application)
 {
     $destination = $application->getResourcesPath('.env');
     if (!is_dir(dirname($destination))) {
         $filesystem->makeDirectory(dirname($destination), 0777, true, true);
     }
     if (is_file($destination) && !$this->command->option('force')) {
         return $this->command->error("{$destination} already exists.");
     }
     $filesystem->put($destination, '#EXAMPLE=foo');
     $this->command->info("Published {$destination}");
 }
 /**
  * Handle the command.
  *
  * @param  Filesystem  $filesystem
  * @param  Application $application
  * @return string
  */
 public function handle(Filesystem $filesystem, Application $application)
 {
     $destination = $application->getResourcesPath('routes.php');
     if (!is_dir(dirname($destination))) {
         $filesystem->makeDirectory(dirname($destination), 0777, true, true);
     }
     if (is_file($destination) && !$this->command->option('force')) {
         return $this->command->error("{$destination} already exists.");
     }
     $content = "<?php\n\n// Route::get('/', function () {\n//     return view('welcome');\n// });\n";
     $filesystem->put($destination, $content);
     $this->command->info("Published {$destination}");
 }
 /**
  * Register an addon.
  *
  * @param $path
  * @param $enabled
  * @param $installed
  */
 public function register($path, array $enabled, array $installed)
 {
     if (!is_dir($path)) {
         return;
     }
     $vendor = strtolower(basename(dirname($path)));
     $slug = strtolower(substr(basename($path), 0, strpos(basename($path), '-')));
     $type = strtolower(substr(basename($path), strpos(basename($path), '-') + 1));
     $class = studly_case($vendor) . '\\' . studly_case($slug) . studly_case($type) . '\\' . studly_case($slug) . studly_case($type);
     /* @var Addon|Module|Extension|Twig_ExtensionInterface $addon */
     $addon = app($class)->setPath($path)->setType($type)->setSlug($slug)->setVendor($vendor);
     // If the addon supports states - set the state now.
     if ($addon->getType() === 'module' || $addon->getType() === 'extension') {
         $addon->setInstalled(in_array($addon->getNamespace(), $installed));
         $addon->setEnabled(in_array($addon->getNamespace(), $enabled));
     }
     // Bind to the service container.
     $this->container->alias($addon->getNamespace(), $alias = get_class($addon));
     $this->container->instance($alias, $addon);
     // Load package configuration.
     $this->configurator->addNamespace($addon->getNamespace(), $addon->getPath('resources/config'));
     // Load system overrides.
     $this->configurator->addNamespaceOverrides($addon->getNamespace(), base_path('resources/addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType()));
     // Load application overrides.
     $this->configurator->addNamespaceOverrides($addon->getNamespace(), $this->application->getResourcesPath('addons/' . $addon->getVendor() . '/' . $addon->getSlug() . '-' . $addon->getType() . '/config'));
     // Continue loading things.
     $this->provider->register($addon);
     // Add the view / translation namespaces.
     $this->views->addNamespace($addon->getNamespace(), $addon->getPath('resources/views'));
     $this->translator->addNamespace($addon->getNamespace(), $addon->getPath('resources/lang'));
     /*
      * If the addon is a plugin then
      * load it into Twig when appropriate.
      */
     if ($addon->getType() === 'plugin') {
         $this->events->listen('Anomaly\\Streams\\Platform\\View\\Event\\RegisteringTwigPlugins', function (RegisteringTwigPlugins $event) use($addon) {
             $twig = $event->getTwig();
             $twig->addExtension($addon);
         });
     }
     $this->collection->put($addon->getNamespace(), $addon);
     $this->events->fire(new AddonWasRegistered($addon));
 }