コード例 #1
0
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     return $this->redirector->to($this->parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
コード例 #2
0
 /**
  * Parse the button with the entry.
  *
  * @param  array $button
  * @param        $entry
  * @return mixed
  */
 public function parser(array $button, $entry)
 {
     if (is_object($entry) && $entry instanceof Arrayable) {
         $entry = $entry->toArray();
     }
     return $this->parser->parse($button, compact('entry'));
 }
コード例 #3
0
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Parser                     $parser
  * @return string
  */
 public function handle(SettingRepositoryInterface $settings, Parser $parser)
 {
     $base = $settings->get('anomaly.module.posts::module_segment', 'posts');
     $structure = $settings->get('anomaly.module.posts::permalink_structure', '{year}/{month}/{day}/{post}');
     $data = ['year' => $this->post->created_at->format('Y'), 'month' => $this->post->created_at->format('m'), 'day' => $this->post->created_at->format('d'), 'post' => $this->post->getSlug()];
     return $parser->parse($base . '/' . $structure, $data);
 }
コード例 #4
0
 /**
  * Handle the command.
  *
  * @param  Decorator $decorator
  * @param  Parser    $parser
  * @return array
  */
 public function handle(Decorator $decorator, Parser $parser)
 {
     $data = [];
     $data['form'] = $this->builder->getFormPresenter();
     $data['fields'] = $decorator->decorate($this->builder->getFormFields());
     $data['subject'] = $parser->parse($this->builder->getOption('subject', 'Contact Request'), $this->builder->getFormValues()->all());
     return $data;
 }
コード例 #5
0
 /**
  * Handle the command.
  *
  * @param RedirectRepositoryInterface $redirects
  * @param Redirector                  $redirector
  * @param Parser                      $parser
  * @param Route                       $route
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(RedirectRepositoryInterface $redirects, Redirector $redirector, Parser $parser, Route $route)
 {
     $redirect = $redirects->find($this->id);
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($route->parameterNames())), $route->parameters());
     return $redirector->to($parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
 /**
  * Handle the command.
  *
  * @param GenerateEntryTranslationsModel $command
  */
 public function handle(GenerateEntryTranslationsModel $command)
 {
     $stream = $command->getStream();
     $data = $this->getTemplateData($stream);
     $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/translation.stub');
     $file = $this->getFilePath($stream);
     @unlink($file);
     file_put_contents($file, $this->parser->parse($template, $data));
 }
コード例 #7
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $path = "{$this->path}/resources/lang/en/addon.php";
     $title = ucwords(str_replace('_', ' ', $this->slug));
     $type = ucwords(str_replace('_', ' ', $this->type));
     $template = $filesystem->get(base_path('vendor/anomaly/streams-platform/resources/stubs/addons/resources/lang/en/addon.stub'));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('title', 'type')));
 }
コード例 #8
0
 /**
  * Handle the command.
  *
  * @param GenerateEntryModel $command
  */
 public function handle(GenerateEntryModel $command)
 {
     $stream = $command->getStream();
     $data = $this->getTemplateData($stream);
     $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/entry.stub');
     $file = $this->getFilePath($stream);
     $this->files->makeDirectory(dirname($file), 0777, true, true);
     $this->files->delete($file);
     $this->files->put($file, $this->parser->parse($template, $data));
 }
コード例 #9
0
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     if (!starts_with($url = $redirect->getTo(), ['http://', 'https://', '//'])) {
         $url = $this->url->to($redirect->getTo(), [], $redirect->isSecure());
     }
     return $this->redirector->to(rtrim($this->parser->parse($url, $parameters), '/'), $redirect->getStatus());
 }
コード例 #10
0
ファイル: GetPostPath.php プロジェクト: ramcda/posts-module
 /**
  * Handle the command.
  *
  * @param SettingRepositoryInterface $settings
  * @param Parser                     $parser
  * @return string
  */
 public function handle(SettingRepositoryInterface $settings, Parser $parser)
 {
     $base = $settings->value('anomaly.module.posts::module_segment', 'posts');
     if (!$this->post->isEnabled()) {
         return $base . '/preview/' . $this->post->getStrId();
     }
     $permalink = $settings->value('anomaly.module.posts::permalink_structure', ['year', 'month', 'day', 'post']);
     $permalink = implode('}/{', $permalink);
     $data = ['year' => $this->post->publish_at->format('Y'), 'month' => $this->post->publish_at->format('m'), 'day' => $this->post->publish_at->format('d'), 'post' => $this->post->getSlug()];
     return $parser->parse($base . '/' . "{{$permalink}}", $data);
 }
コード例 #11
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $suffix = ucfirst(camel_case($this->slug));
     $segment = $this->slug;
     $addon = $this->addon->getSlug();
     $controller = $this->addon->getTransformedClass("Http\\Controller\\Admin\\{$suffix}Controller");
     $path = $this->addon->getPath("resources/routes/{$this->slug}.php");
     $template = $filesystem->get(base_path("vendor/anomaly/streams-platform/resources/stubs/entity/http/routes.stub"));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('addon', 'segment', 'controller')));
 }
コード例 #12
0
 /**
  * Handle the command.
  *
  * @param Filesystem  $files
  * @param Parser      $parser
  * @param Application $application
  */
 public function handle(Filesystem $files, Parser $parser, Application $application)
 {
     $data = ['class' => (new EntryClassParser())->parse($this->stream), 'title' => (new EntryTitleParser())->parse($this->stream), 'table' => (new EntryTableParser())->parse($this->stream), 'rules' => (new EntryRulesParser())->parse($this->stream), 'dates' => (new EntryDatesParser())->parse($this->stream), 'stream' => (new EntryStreamParser())->parse($this->stream), 'trashable' => (new EntryTrashableParser())->parse($this->stream), 'relations' => (new EntryRelationsParser())->parse($this->stream), 'namespace' => (new EntryNamespaceParser())->parse($this->stream), 'field_slugs' => (new EntryFieldSlugsParser())->parse($this->stream), 'searchable' => (new EntrySearchableParser())->parse($this->stream), 'relationships' => (new EntryRelationshipsParser())->parse($this->stream), 'translation_model' => (new EntryTranslationModelParser())->parse($this->stream), 'translated_attributes' => (new EntryTranslatedAttributesParser())->parse($this->stream), 'translation_foreign_key' => (new EntryTranslationForeignKeyParser())->parse($this->stream)];
     $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/entry.stub');
     $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace()));
     $files->makeDirectory($path, 0777, true, true);
     $file = $path . '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug()) . 'EntryModel.php';
     $files->makeDirectory(dirname($file), 0777, true, true);
     $files->delete($file);
     $files->put($file, $parser->parse($template, $data));
 }
コード例 #13
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $path = "{$this->path}/composer.json";
     $slug = $this->slug;
     $type = $this->type;
     $vendor = $this->vendor;
     $prefix = ucfirst(camel_case($vendor)) . '\\\\' . ucfirst(camel_case($slug)) . ucfirst(camel_case($type)) . '\\\\';
     $template = $filesystem->get(base_path('vendor/anomaly/streams-platform/resources/stubs/addons/composer.stub'));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('vendor', 'slug', 'type', 'prefix')));
 }
コード例 #14
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $suffix = ucfirst(camel_case($this->slug));
     $entity = str_singular($suffix);
     $class = "{$entity}TableBuilder";
     $namespace = $this->addon->getTransformedClass("{$entity}\\Table");
     $path = $this->addon->getPath("src/{$entity}/Table/{$entity}TableBuilder.php");
     $template = $filesystem->get(base_path("vendor/anomaly/streams-platform/resources/stubs/entity/table/builder.stub"));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('class', 'namespace')));
 }
コード例 #15
0
 /**
  * Handle the comand.
  *
  * @param Parser      $parser
  * @param Application $application
  */
 public function handle(Parser $parser, Application $application)
 {
     $data = ['namespace' => (new EntryNamespaceParser())->parse($this->stream), 'class' => (new EntryTranslationsClassParser())->parse($this->stream), 'table' => (new EntryTranslationsTableParser())->parse($this->stream)];
     $template = file_get_contents(__DIR__ . '/../../../resources/stubs/models/translation.stub');
     $path = $application->getStoragePath('models/' . studly_case($this->stream->getNamespace()));
     $path .= '/' . studly_case($this->stream->getNamespace()) . studly_case($this->stream->getSlug());
     $file = $path . 'EntryTranslationsModel.php';
     @unlink($file);
     // Don't judge me..
     file_put_contents($file, $parser->parse($template, $data));
 }
コード例 #16
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $slug = ucfirst(camel_case($this->slug));
     $type = ucfirst(camel_case($this->type));
     $vendor = ucfirst(camel_case($this->vendor));
     $addon = $slug . $type;
     $namespace = "{$vendor}\\{$addon}";
     $path = "{$this->path}/src/{$addon}.php";
     $template = $filesystem->get(base_path("vendor/anomaly/streams-platform/resources/stubs/addons/{$this->type}.stub"));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('namespace', 'addon')));
 }
コード例 #17
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $suffix = ucfirst(camel_case($this->slug));
     $prefix = ucfirst(camel_case($this->namespace));
     $entity = str_singular($suffix);
     $model = "{$entity}Model";
     $class = "{$entity}Repository";
     $implements = "{$entity}RepositoryInterface";
     $namespace = $this->addon->getTransformedClass("{$entity}");
     $interface = $this->addon->getTransformedClass("{$entity}\\Contract\\{$entity}RepositoryInterface");
     $path = $this->addon->getPath("src/{$entity}/{$entity}Repository.php");
     $template = $filesystem->get(base_path("vendor/anomaly/streams-platform/resources/stubs/entity/repository.stub"));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('model', 'class', 'implements', 'namespace', 'interface')));
 }
コード例 #18
0
 /**
  * Handle the command.
  *
  * @param Parser     $parser
  * @param Filesystem $filesystem
  */
 public function handle(Parser $parser, Filesystem $filesystem)
 {
     $suffix = ucfirst(camel_case($this->slug));
     $entity = str_singular($suffix);
     $class = "{$suffix}Controller";
     $form = "{$entity}FormBuilder";
     $table = "{$entity}TableBuilder";
     $namespace = $this->addon->getTransformedClass("Http\\Controller\\Admin");
     $formBuilder = $this->addon->getTransformedClass("{$entity}\\Form\\{$entity}FormBuilder");
     $tableBuilder = $this->addon->getTransformedClass("{$entity}\\Table\\{$entity}TableBuilder");
     $path = $this->addon->getPath("src/Http/Controller/Admin/{$suffix}Controller.php");
     $template = $filesystem->get(base_path("vendor/anomaly/streams-platform/resources/stubs/entity/http/controller/admin.stub"));
     $filesystem->makeDirectory(dirname($path), 0755, true, true);
     $filesystem->put($path, $parser->parse($template, compact('class', 'namespace', 'formBuilder', 'tableBuilder', 'form', 'table')));
 }
コード例 #19
0
 /**
  * Copy a directoy from one location to another.
  *
  * @param  string  $source
  * @param  string  $destination
  * @param  array   $data
  * @param  int     $options
  * @return bool
  */
 public function parseDirectory($source, $destination, $data, $options = null)
 {
     if (!$this->isDirectory($source)) {
         return false;
     }
     $options = $options ?: FilesystemIterator::SKIP_DOTS;
     // If the destination destination does not actually exist, we will go ahead and
     // create it recursively, which just gets the destination prepared to copy
     // the files over. Once we make the source we'll proceed the copying.
     if (!$this->isDirectory($destination)) {
         $this->makeDirectory($destination, 0777, true);
     }
     $items = new FilesystemIterator($source, $options);
     foreach ($items as $item) {
         // As we spin through items, we will check to see if the current file is actually
         // a source or a file. When it is actually a source we will need to call
         // back into this function recursively to keep copying these nested folders.
         $target = $destination . '/' . $this->parser->parse($item->getBasename(), $data);
         if ($item->isDir()) {
             $path = $item->getPathname();
             if (!$this->parseDirectory($path, $target, $data, $options)) {
                 return false;
             }
         } else {
             $template = file_get_contents($item->getPathname());
             $this->put($target, $this->parser->parse($template, $data));
         }
     }
     return true;
 }
コード例 #20
0
 /**
  * Handle the form response.
  *
  * @param FormBuilder $builder
  */
 public function handle(FormBuilder $builder)
 {
     /**
      * If the form already has a response
      * then we're being overridden. Abort!
      */
     if ($builder->getFormResponse()) {
         return;
     }
     $entry = $builder->getFormEntry();
     $actions = $builder->getFormActions();
     $action = $actions->active();
     if ($entry && $entry instanceof Arrayable) {
         $entry = $entry->toArray();
     }
     $redirect = $action->getRedirect();
     if ($redirect instanceof RedirectResponse) {
         $builder->setFormResponse($redirect);
         return;
     }
     if ($redirect === false) {
         return;
     }
     $redirect = $this->parser->parse($redirect, compact('entry'));
     /**
      * If the redirect is null then use the current one.
      */
     if ($redirect === null) {
         $redirect = $this->redirector->back()->getTargetUrl();
     }
     /**
      * If the URL is a closure then call it.
      */
     if ($redirect instanceof \Closure) {
         $redirect = app()->call($redirect, compact('builder'));
     }
     $builder->setFormResponse($this->redirector->to($redirect));
 }
コード例 #21
0
 /**
  * Handle the command.
  *
  * @param SettingRepository $settings
  */
 public function handle(SettingRepository $settings, Parser $parser)
 {
     $input = $this->builder->getFormValues()->all();
     call_user_func_array([$this->message, 'to'], $parser->parse((array) $this->builder->getOption('to', $settings->get('streams::contact_email', env('CONTACT_EMAIL', env('ADMIN_EMAIL')))), $input));
     if ($cc = (array) $this->builder->getOption('cc', null)) {
         call_user_func_array([$this->message, 'cc'], $parser->parse($cc, $input));
     }
     if ($bcc = (array) $this->builder->getOption('bcc', null)) {
         call_user_func_array([$this->message, 'bcc'], $parser->parse($bcc, $input));
     }
     call_user_func_array([$this->message, 'from'], $parser->parse((array) $this->builder->getOption('from', $settings->get('streams::server_email', '*****@*****.**')), $input));
     call_user_func_array([$this->message, 'subject'], (array) $parser->parse($this->builder->getOption('subject', 'Contact Request'), $input));
 }
コード例 #22
0
ファイル: Value.php プロジェクト: huglester/streams-platform
 /**
  * Make a value from the parameters and entry.
  *
  * @param               $parameters
  * @param               $payload
  * @param  array        $payload
  * @return mixed|string
  */
 public function make($parameters, $entry, $term = 'entry', $payload = [])
 {
     $payload[$term] = $entry;
     /*
      * If a flat value was sent in
      * then convert it to an array.
      */
     if (!is_array($parameters)) {
         $parameters = ['value' => $parameters];
     }
     $value = array_get($parameters, 'value');
     /*
      * If the value is a view path then return a view.
      */
     if ($view = array_get($parameters, 'view')) {
         return view($view, ['value' => $value, $term => $entry]);
     }
     /*
      * If the value uses a template then parse it.
      */
     if ($template = array_get($parameters, 'template')) {
         return $this->template->render($template, ['value' => $value, $term => $entry]);
     }
     /*
      * If the entry is an instance of EntryInterface
      * then try getting the field value from the entry.
      */
     if ($entry instanceof EntryInterface && $entry->getField($value)) {
         /* @var EntryInterface $relation */
         if ($entry->assignmentIsRelationship($value) && ($relation = $entry->{camel_case($value)})) {
             if ($relation instanceof EloquentModel) {
                 $value = $relation->getTitle();
             }
         } else {
             $value = $entry->getFieldValue($value);
         }
     }
     /*
      * Decorate the entry object before
      * sending to decorate so that data_get()
      * can get into the presenter methods.
      */
     $payload[$term] = $entry = $this->decorator->decorate($entry);
     /*
      * If the value matches a dot notation
      * then parse it as a template.
      */
     if (is_string($value) && preg_match("/^{$term}.([a-zA-Z\\_]+)/", $value, $match)) {
         $value = $this->template->render("{{ {$value}|raw }}", $payload);
     }
     /*
      * If the value matches a method in the presenter.
      */
     if (is_string($value) && preg_match("/^{$term}.([a-zA-Z\\_]+)/", $value, $match)) {
         if (method_exists($entry, camel_case($match[1]))) {
             $value = $entry->{camel_case($match[1])}();
         }
     }
     $payload[$term] = $entry;
     /*
      * By default we can just pass the value through
      * the evaluator utility and be done with it.
      */
     $value = $this->evaluator->evaluate($value, $payload);
     /*
      * Lastly, prepare the entry to be
      * parsed into the string.
      */
     if ($entry instanceof Arrayable) {
         $entry = $entry->toArray();
     }
     /*
      * Parse the value with the entry.
      */
     if ($wrapper = array_get($parameters, 'wrapper')) {
         $value = $this->parser->parse($wrapper, ['value' => $value, $term => $entry]);
     }
     /*
      * Parse the value with the value too.
      */
     if (is_string($value)) {
         $value = $this->parser->parse($value, ['value' => $value, $term => $entry]);
     }
     /*
      * If the value looks like a language
      * key then try translating it.
      */
     if (is_string($value) && str_is('*.*.*::*', $value)) {
         $value = trans($value);
     }
     /*
      * If the value looks like a render-able
      * string then render it.
      */
     if (is_string($value) && str_contains($value, '{{')) {
         $value = $this->template->render($value, [$term => $entry]);
     }
     return $value;
 }
コード例 #23
0
 /**
  * Parse the segments.
  *
  * @param TreeBuilder $builder
  */
 public function parse(TreeBuilder $builder)
 {
     $builder->setSegments($this->parser->parse($builder->getSegments()));
 }
コード例 #24
0
 /**
  * Parse the button with the entry.
  *
  * @param array $button
  * @param       $entry
  */
 public function parse(array $button, $entry)
 {
     /* @var Arrayable $entry */
     $entry = $entry->toArray();
     return $this->parser->parse($button, compact('entry'));
 }
コード例 #25
0
 /**
  * Parse the button with the entry.
  *
  * @param  array $button
  * @param        $entry
  * @return array
  */
 public function parse(array $button, $entry)
 {
     return $this->parser->parse($button, compact('entry'));
 }
コード例 #26
0
 /**
  * Parse the control panel buttons.
  *
  * @param ControlPanelBuilder $builder
  */
 public function parse(ControlPanelBuilder $builder)
 {
     $parameters = $this->request->route()->parameters();
     $builder->setButtons($this->parser->parse($builder->getButtons(), compact('parameters')));
 }
コード例 #27
0
 /**
  * Parse the form fields.
  *
  * @param FormBuilder $builder
  */
 public function parse(FormBuilder $builder)
 {
     $entry = $builder->getFormEntry();
     $builder->setFields($this->parser->parse($builder->getFields(), compact('entry')));
 }
コード例 #28
0
 /**
  * Parse the table buttons.
  *
  * @param TableBuilder $builder
  */
 public function parse(TableBuilder $builder)
 {
     $builder->setActions($this->parser->parse($builder->getActions()));
 }
コード例 #29
0
 /**
  * Return the parsed target.
  *
  * @param               $target
  * @param FileFieldType $fieldType
  * @return mixed
  */
 public function parse($target, FileFieldType $fieldType)
 {
     $entry = $fieldType->getEntry();
     return $this->parser->parse($target, compact('entry'));
 }
コード例 #30
0
 /**
  * Parse the control panel sections.
  *
  * @param ControlPanelBuilder $builder
  */
 public function parse(ControlPanelBuilder $builder)
 {
     $builder->setSections($this->parser->parse($builder->getSections()));
 }