Автор: XE Team (developers) (developers@xpressengine.com)
Наследование: extends NamespacedItemResolver, implements Symfony\Component\Translation\TranslatorInterface
 public function updateItem(Translator $translator, Request $request, $id)
 {
     /** @var CategoryItem $item */
     if (!($item = CategoryItem::find($request->get('id')))) {
         throw new InvalidArgumentHttpException();
     }
     $item->fill($request->all());
     XeCategory::putItem($item);
     $multiLang = $translator->getPreprocessorValues($request->all(), session()->get('locale'));
     $item->readableWord = $multiLang['word'];
     return XePresenter::makeApi($item->toArray());
 }
Пример #2
0
 /**
  * Make title text
  *
  * @param SeoUsable $item item instance
  * @return string
  */
 protected function makeTitle(SeoUsable $item = null)
 {
     if ($item) {
         return $item->getTitle() . ' - ' . $this->translator->trans($this->setting->get('mainTitle'));
     }
     return implode(' - ', [$this->translator->trans($this->setting->get('mainTitle')), $this->translator->trans($this->setting->get('subTitle'))]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $name = $this->input->getArgument('name');
     $path = $this->input->getOption('path');
     if ($path && !file_exists(base_path($path))) {
         $this->error(sprintf('Not exists [%s]', base_path($path)));
         return;
     }
     $files = [];
     if ($path && !is_dir(base_path($path))) {
         $files = [base_path($path)];
     } else {
         $dirPath = !$path ? $this->getLangsDir($name) : base_path($path);
         $dir = dir($dirPath);
         while ($entry = $dir->read()) {
             $path = $dirPath . DIRECTORY_SEPARATOR . $entry;
             if (is_dir($path)) {
                 continue;
             }
             $files[] = $path;
         }
     }
     foreach ($files as $file) {
         $this->translator->putFromLangDataSource($this->getNamespace($name), $file);
     }
     $this->info('Language import complete!');
 }
Пример #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $namespace = $this->input->getOption('ns');
     if ($namespace == false) {
         $this->error('네임스페이스를 입력하세요.');
         return null;
     }
     $path = $this->input->getOption('path');
     if ($path == false) {
         $this->error('다국어 파일 위치를 입력하세요.');
         return null;
     }
     $path = base_path($path);
     if (file_exists($path) === false) {
         $this->error('다국어 파일을 찾을 수 없습니다.');
         return null;
     }
     $this->translator->putFromLangDataSource($namespace, $path);
     $this->info('Language import complete!');
 }
 /**
  * update dynamic field
  *
  * @return \Xpressengine\Presenter\RendererInterface
  */
 public function update(Request $request, Translator $translator)
 {
     /**
      * @var \Xpressengine\DynamicField\DynamicFieldHandler $dynamicField
      */
     $dynamicField = app('xe.dynamicField');
     $inputs = $request->all();
     unset($inputs['databaseName']);
     /**
      * @var \Xpressengine\DynamicField\RegisterHandler $registerHandler
      */
     $registerHandler = $dynamicField->getRegisterHandler();
     $rules = DynamicFieldSection::getRules();
     $fieldType = $registerHandler->getSkin($dynamicField, $inputs['typeId']);
     $fieldSkin = $registerHandler->getSkin($dynamicField, $inputs['skinId']);
     $rules = array_merge($rules, $fieldType->getSettingsRules(), $fieldSkin->getSettingsRules());
     $this->validate($request->instance(), $rules);
     $configHandler = $dynamicField->getConfigHandler();
     $config = $configHandler->get($inputs['group'], $inputs['id']);
     foreach ($inputs as $name => $value) {
         $config->set($name, $value);
     }
     $dynamicField->setConnection(XeDB::connection($request->get('databaseName')));
     $dynamicField->put($config);
     $row = $config->getPureAll();
     $fieldType = $registerHandler->getType($dynamicField, $row['typeId']);
     $fieldSkin = $registerHandler->getSkin($dynamicField, $row['skinId']);
     $row['typeName'] = $fieldType->name();
     $row['skinName'] = $fieldSkin->name();
     $multiLang = $translator->getPreprocessorValues($inputs, session()->get('locale'));
     $row['label'] = $multiLang['label'];
     return XePresenter::makeApi($row);
 }