/** * Update/migrate an extension. * * @param \Orchestra\Contracts\Extension\Listener\Migrator $listener * @param \Illuminate\Support\Fluent $extension * * @return mixed */ public function migrate(Listener $listener, Fluent $extension) { if (!$this->factory->started($extension->get('name'))) { return $listener->abortWhenRequirementMismatched(); } return $this->execute($listener, 'migration', $extension, $this->getMigrationClosure()); }
/** * Update setting. * * @param \Orchestra\Contracts\Foundation\Listener\SettingUpdater $listener * @param array $input * * @return mixed */ public function update(SettingUpdateListener $listener, array $input) { $input = new Fluent($input); $driver = $this->getValue($input['email_driver'], 'mail.driver'); $validation = $this->validator->on($driver)->with($input->toArray()); if ($validation->fails()) { return $listener->settingFailedValidation($validation->getMessageBag()); } $memory = $this->memory; $memory->put('site.name', $input['site_name']); $memory->put('site.description', $input['site_description']); $memory->put('site.registrable', $input['site_registrable'] === 'yes'); $memory->put('email.driver', $driver); $memory->put('email.from', ['address' => $this->getValue($input['email_address'], 'mail.from.address'), 'name' => $input['site_name']]); if (empty($input['email_password']) && $input['enable_change_password'] === 'no') { $input['email_password'] = $memory->get('email.password'); } if (empty($input['email_secret']) && $input['enable_change_secret'] === 'no') { $input['email_secret'] = $memory->get('email.secret'); } $memory->put('email.host', $this->getValue($input['email_host'], 'mail.host')); $memory->put('email.port', $this->getValue($input['email_port'], 'mail.port')); $memory->put('email.username', $this->getValue($input['email_username'], 'mail.username')); $memory->put('email.password', $this->getValue($input['email_password'], 'mail.password')); $memory->put('email.encryption', $this->getValue($input['email_encryption'], 'mail.encryption')); $memory->put('email.sendmail', $this->getValue($input['email_sendmail'], 'mail.sendmail')); $memory->put('email.queue', $input['email_queue'] === 'yes'); $memory->put('email.key', $this->getValue($input['email_key'], "services.{$driver}.key")); $memory->put('email.secret', $this->getValue($input['email_secret'], "services.{$driver}.secret")); $memory->put('email.domain', $this->getValue($input['email_domain'], "services.{$driver}.domain")); $memory->put('email.region', $this->getValue($input['email_region'], "services.{$driver}.region")); Event::fire('orchestra.saved: settings', [$memory, $input]); return $listener->settingHasUpdated(); }
/** * Determing if it is just an empty directory * * @return bool */ public function isEmptyDir() { $emptyDir = $this->ingredient->get('empty-dir'); if (is_null($emptyDir)) { return false; } return $emptyDir; }
/** * Deactivate an extension. * * @param \Orchestra\Contracts\Extension\Listener\Deactivator $listener * @param \Illuminate\Support\Fluent $extension * * @return mixed */ public function deactivate(Listener $listener, Fluent $extension) { if (!$this->factory->started($extension->get('name')) && !$this->factory->activated($extension->get('name'))) { return $listener->abortWhenRequirementMismatched(); } $this->factory->deactivate($extension->get('name')); return $listener->deactivationHasSucceed($extension); }
/** * Vaildate if expression contains the reserve keys * * @param array $expression * @return boolean * @throws \Elepunk\Evaluator\Exceptions\MissingKeyException */ protected function verifyExpression(Fluent $expression) { foreach ($this->reservedKeys as $key) { if (is_null($expression->get($key))) { throw new MissingKeyException("Expression is missing {$key}"); } } return true; }
/** * Send the request after setting authorization params * @return Illuminate\Http\Response */ public function sendAuthorization() { $this->request->merge($this->params->toArray()); $this->oauth->getIssuer()->setRequest($this->request); $token = $this->oauth->issueAccessToken(); if (auth()->check()) { $token['user'] = auth()->user(); } return response()->json($token); }
/** * Execute extension processing. * * @param object $listener * @param string $type * @param \Illuminate\Support\Fluent $extension * @param \Closure $callback * * @return mixed */ protected function execute($listener, $type, Fluent $extension, Closure $callback) { $name = $extension->get('name'); try { // Check if folder is writable via the web instance, this would // avoid issue running Orchestra Platform with debug as true where // creating/copying the directory would throw an ErrorException. if (!$this->factory->permission($name)) { throw new FilePermissionException("[{$name}] is not writable."); } call_user_func($callback, $this->factory, $name); } catch (FilePermissionException $e) { return call_user_func([$listener, "{$type}HasFailed"], $extension, ['error' => $e->getMessage()]); } return call_user_func([$listener, "{$type}HasSucceed"], $extension); }
public function get($key, $default = null) { if ($key === 'date') { return $this->dateTime(); } return parent::get($key, $default); }
/** * Magic method to get items by key. * * @param string $key * * @return mixed */ public function __get($key) { if (!isset($this->items->{$key})) { return; } return $this->items->get($key); }
public function __construct($fileinfo) { if ($fileinfo instanceof SplFileInfo === false) { $fileinfo = new SplFileInfo($fileinfo); } parent::__construct($this->parseFileInfo($fileinfo)); $this->fileinfo = $fileinfo; }
public function __construct($data) { $steamID = isset($data['steamid']) ? $data['steamid'] : null; unset($data['steamid']); parent::__construct($data); $this->attributes['steamID64'] = $steamID; $this->attributes['steamID'] = $this->getSteamID($steamID); }
/** * {@inheritdoc} */ public function __construct($attributes) { // Default attributes if (is_string($attributes)) { $attributes = ['command' => $attributes, 'status' => null, 'output' => null, 'done' => false]; } parent::__construct($attributes); $this->sanitized = $this->sanitizeCommand($this->command); }
/** * Theme constructor. * * @param string $name * @param string $theme * @param string $type * @param string $version * @param string $description * @param array $positions * @param array|object $attributes */ public function __construct($name, $theme, $type, $version, $description, array $positions, $attributes = []) { $this->name = $name; $this->theme = $theme; $this->type = $type; $this->version = $version; $this->description = $description; $this->positions = $positions; parent::__construct($attributes); }
/** * FluentParameters constructor. * * @param array|object $attributes */ public function __construct($attributes) { parent::__construct($attributes); if (isset($attributes['templates']) && is_array($attributes['templates'])) { $templates = new Collection(); foreach ($attributes['templates'] as $template) { $templates->push(new Fluent($template)); } $this->templates = $templates; } }
/** * @param array $attributes */ public function __construct($attributes = []) { $attributes['orderable'] = isset($attributes['orderable']) ? $attributes['orderable'] : true; $attributes['searchable'] = isset($attributes['searchable']) ? $attributes['searchable'] : true; // Allow methods override attribute value foreach ($attributes as $attribute => $value) { $method = 'parse' . ucfirst(strtolower($attribute)); if (method_exists($this, $method)) { $attributes[$attribute] = $this->{$method}($value); } } parent::__construct($attributes); }
/** * Update an extension configuration. * * @param \Orchestra\Contracts\Extension\Listener\Configure $listener * @param \Illuminate\Support\Fluent $extension * @param array $input * * @return mixed */ public function update(Listener $listener, Fluent $extension, array $input) { if (!Extension::started($extension->get('name'))) { return $listener->suspend(404); } $validation = $this->validator->with($input, ["orchestra.validate: extension.{$extension->get('name')}"]); if ($validation->fails()) { return $listener->updateConfigurationFailedValidation($validation->getMessageBag(), $extension->uid); } $memory = Foundation::memory(); $config = (array) $memory->get("extension.active.{$extension->get('name')}.config", []); $input = new Fluent(array_merge($config, $input)); unset($input['_token']); Event::fire("orchestra.saving: extension.{$extension->get('name')}", [&$input]); $memory->put("extensions.active.{$extension->get('name')}.config", $input->getAttributes()); $memory->put("extension_{$extension->get('name')}", $input->getAttributes()); Event::fire("orchestra.saved: extension.{$extension->get('name')}", [$input]); return $listener->configurationUpdated($extension); }
/** * Response when extension deactivation has succeed. * * @param \Illuminate\Support\Fluent $extension * * @return mixed */ public function deactivationHasSucceed(Fluent $extension) { $this->refreshRouteCache(); $this->info("Extension [{$extension->get('name')}] deactivated."); }
/** * @param SelfSMSProvider $provider Base provider * @param array $options Preset options */ public function __construct(SelfSMSProvider $provider, $options = []) { parent::__construct($options); $this->provider = $provider; }
/** * Compile a primary key command. * * @param \Illuminate\Database\Schema\Blueprint $blueprint * @param \Illuminate\Support\Fluent $command * @return string */ public function compilePrimary(Blueprint $blueprint, Fluent $command) { $command->name(null); return $this->compileKey($blueprint, $command, 'primary key'); }
/** * Queue publishing asset to publisher. * * @param \Illuminate\Support\Fluent $extension * * @return mixed */ protected function queueToPublisher(Fluent $extension) { Publisher::queue($extension->get('name')); return $this->redirect(handles('orchestra::publisher')); }
/** * Status constructor * * @param ResultInterface $result Result instance * @param array $status Status array */ public function __construct(ResultInterface $result, array $status) { $this->setResult($result); parent::__construct($status); }
/** * Response when update extension configuration succeed. * * @param \Illuminate\Support\Fluent $extension * * @return mixed */ public function configurationUpdated(Fluent $extension) { $this->dispatch(new RefreshRouteCache()); $message = trans('orchestra/foundation::response.extensions.configure', $extension->getAttributes()); return $this->redirectWithMessage(handles('orchestra::extensions'), $message); }
// Array dot notation (and other helpers) $person = ['name' => ['first' => 'Jill', 'last' => 'Schmoe']]; echo 'name.first is ' . array_get($person, 'name.first') . "\n"; $messageBag->add('notice', 'Array dot notation displayed.'); echo '<hr>'; // Collection $people = new Collection(['Declan', 'Abner', 'Mitzi']); $people->each(function ($person) { echo "Collection person: {$person}\n"; }); $messageBag->add('notice', 'Collection displayed.'); echo '<hr>'; // More at http://daylerees.com/codebright/eloquent-collections // Fluent $personRecord = array('first_name' => 'Mohammad', 'last_name' => 'Gufran'); $record = new Fluent($personRecord); $record->address('hometown, street, house'); echo $record->first_name . "\n"; echo $record->address . "\n"; $messageBag->add('notice', 'Fluent displayed.'); echo '<hr>'; // Pluralizer $item = 'goose'; echo "One {$item}, two " . Pluralizer::plural($item) . "\n"; $item = 'moose'; echo "One {$item}, two " . Pluralizer::plural($item) . "\n"; echo '<hr>'; // Str if (Str::contains('This is my fourteenth visit', 'first')) { echo 'Howdy!'; } else {
/** * Response when sync roles succeed. * * @param \Illuminate\Support\Fluent $acl * * @return mixed */ public function syncSucceed(Fluent $acl) { $message = trans('orchestra/control::response.acls.sync-roles', ['name' => $acl->get('name')]); return $this->redirectWithMessage(handles("orchestra::control/acl?name={$acl->get('name')}"), $message); }
/** * @param string $key * @param mixed|null $default * @return mixed */ public function get($key, $default = null) { $value = parent::get($key, $default); return $this->hasGetMutator($key) ? $this->mutateAttribute($key, $value) : $value; }
/** * @param array $attributes */ public function __construct($attributes = []) { $attributes['orderable'] = isset($attributes['orderable']) ? $attributes['orderable'] : true; $attributes['searchable'] = isset($attributes['searchable']) ? $attributes['searchable'] : true; parent::__construct($attributes); }
/** * Response when extension migration has succeed. * * @param \Illuminate\Support\Fluent $extension * * @return mixed */ public function migrationHasSucceed(Fluent $extension) { $this->info("Extension [{$extension->get('name')}] updated."); }
/** * @param $value * @param Fluent $ruleArgs * @return Carbon */ public function buildTimestamp($value, $ruleArgs) { if (is_null($value)) { return $this->newDateObject(); } if ($value instanceof \DateTime) { return $this->newDateFromTimestamp($value->getTimestamp(), $value->getTimezone()); } if (is_numeric($value)) { return $this->newDateFromTimestamp($value); } elseif (is_string($value) && preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) { return $this->newDateObject($value, 'Y-m-d'); } else { return $this->newDateObject($value, $ruleArgs->get('format')); } }
/** * Resolve field value. * * @param string $name * @param mixed $row * @param \Illuminate\Support\Fluent $control * * @return mixed */ protected function resolveFieldValue($name, $row, Fluent $control) { // Set the value from old input, followed by row value. $value = $this->request->old($name); $model = data_get($row, $name); if (!is_null($model) && is_null($value)) { $value = $model; } if (is_null($control->get('value'))) { return $value; } $value = $control->get('value'); // If the value is set from the closure, we should use it instead of // value retrieved from attached data. Should also check if it's a // closure, when this happen run it. if ($value instanceof Closure) { $value = $value($row, $control); } return $value; }
public function __construct(array $attributes = []) { parent::__construct($attributes); }