Ejemplo n.º 1
0
 public function __construct($words = null)
 {
     if (!$words) {
         $words = (include AbstractApp::getRootDir() . '/app/config/words.php');
     }
     $this->words = $words;
     $this->count = count($words);
 }
Ejemplo n.º 2
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $man = AbstractApp::get('elastic2');
     /* @var $man ElasticSearch2 */
     $list = $man->listIndexes($output);
     foreach ($list as $name) {
         $output->writeln("index: {$name}");
     }
 }
Ejemplo n.º 3
0
 /**
  * Constructor.
  *
  * @param FileLocatorInterface        $locator A FileLocatorInterface instance
  * @param TemplateNameParserInterface $parser  A TemplateNameParserInterface instance
  */
 public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $parser)
 {
     parent::__construct(array());
     $this->locator = $locator;
     $this->parser = $parser;
     $this->cache = array();
     $container = AbstractApp::getCont();
     // no niestety pojawiły się problemy z nadpisywaniem tego serwisu, później może zrobię to tak jak Bóg nakazał...
     // ale to nie jest pilne bo logicznie wszystko tutaj jest poprawne ale nie wedłóg konwencji symfonowej
     $this->container = $container;
     $this->dev = $container->getParameter('kernel.environment') == 'dev';
     $this->symlinkloader = AbstractApp::getStpaConfig('yui.symlinkloader', false);
     $this->loader = is_string($this->symlinkloader) ? trim($this->symlinkloader) : '';
 }
Ejemplo n.º 4
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $man = AbstractApp::get('elastic2');
     /* @var $man ElasticSearch2 */
     $host = $this->getContainer()->getParameter('elastic.host');
     $output->writeln("<info>Server: {$host}</info>");
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion("Target server is: <info>{$host}</info>, do you want to continue? (y|n) : ", false, '/^(y|j)/i');
     if ($input->getOption('force') || $helper->ask($input, $output, $question)) {
         $man->populate($input->getOption('index'), $output);
     } else {
         $output->writeln("Aborted");
     }
 }
Ejemplo n.º 5
0
 public static function encode($data, $options = 0, $depth = 512)
 {
     if ($data === false) {
         return 'false';
     }
     if (AbstractApp::isDev()) {
         $tmp = PrettyJson::encode($data, $options = PrettyJson::JSON_PRETTY_PRINT | PrettyJson::JSON_FORCEUTF8 | PrettyJson::JSON_UNESCAPED_SLASHES | PrettyJson::JSON_UNESCAPED_UNICODE, $depth);
     } else {
         if (version_compare(PHP_VERSION, '5.4.0', '<')) {
             $tmp = json_encode($data, $options);
         } else {
             $tmp = json_encode($data, $options, $depth);
         }
     }
     if ($tmp === false) {
         throw new Exception('conditional: Nie powiodło się przekształcenie za pomocą json_encode' . print_r($data, true));
     }
     return $tmp;
 }
Ejemplo n.º 6
0
 public function ver()
 {
     if (!$this->ver) {
         $root = AbstractApp::getRootDir();
         $file = $root . '/app/cache/prod/appProdUrlMatcher.php';
         try {
             UtilFilesystem::checkFile($file);
         } catch (\Exception $e) {
             $file = $root . '/vendor/autoload.php';
             try {
                 UtilFilesystem::checkFile($file);
             } catch (\Exception $e) {
                 echo "File '{$file}'' not exists, please run project in production mode once to create it\n";
                 die($e->getMessage());
             }
         }
         $d = new DateTime(date("c", filemtime($file)));
         $this->ver = $d->format('Y-m-d-H-i-s');
     }
     return $this->ver;
 }
Ejemplo n.º 7
0
 /**
  * @param type   $pattern
  * @param string $namespacepart - można podać kawałek namespace np: /Console/
  *
  * @return type
  */
 public static function findClasses($fileregexp, $classregexp, $notclassregexp = null)
 {
     $path = realpath(AbstractApp::getRootDir());
     $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
     foreach ($objects as $file => $object) {
         /* @var $object SplFileInfo */
         if (!$object->isLink() && $object->isFile() && preg_match($fileregexp, $file)) {
             //                echo "$file - file\n";
             require_once $file;
         }
     }
     $list = array();
     foreach (get_declared_classes() as $namespace) {
         if (preg_match($classregexp, $namespace)) {
             if ($notclassregexp && preg_match($notclassregexp, $namespace)) {
                 continue;
             }
             //                echo "$namespace\n";
             $list[] = $namespace;
         }
     }
     return $list;
 }
Ejemplo n.º 8
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // tworzenie katalogu głównego /app
     $app = AbstractApp::getStpaConfig('core.app');
     if (!file_exists($app)) {
         UtilFilesystem::checkDir(dirname($app), true);
         $output->writeln("<info>Tworzenie katalogu: </info><comment>{$app}</comment>");
         mkdir($app);
     }
     $list = $this->_findPartsClasses();
     if ($input->getOption('list') === false) {
         foreach ($list as $cls) {
             /* @var $cls AbstractInstallerPart */
             $cls->install($input, $output);
         }
     } else {
         $tmp = array();
         foreach ($list as $cls) {
             /* @var $cls AbstractInstallerPart */
             $tmp[] = str_pad($cls->getPrior(), 8, ' ', STR_PAD_LEFT) . ' : ' . get_class($cls);
         }
         $output->writeln(implode("\n", $tmp));
     }
 }
Ejemplo n.º 9
0
 public static function getConfig()
 {
     return array('class' => Comment::getClassNamespace(), 'web' => AbstractApp::getRootDir() . '/web', 'dirtmp' => '/media/uploads/comments_tmp', 'dir' => '/media/uploads/comments', 'file' => '#^user\\.comments\\.\\d+\\.file#', 'field' => 'path');
 }
Ejemplo n.º 10
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param string|array    $em
  */
 protected function init(InputInterface $input, OutputInterface $output, $em = null)
 {
     $this->input = $input;
     $this->output = $output;
     if ($em === false) {
         return;
     }
     if ($em === true) {
         $em = 'default';
     }
     if (is_null($em)) {
         throw new Exception("Ustaw najpierw parametr 'em' np: 'old' lub ustaw wartość 'true' aby wybrać domyślny manager. " . __METHOD__);
     }
     if (is_string($em)) {
         $this->em = AbstractApp::get("doctrine.orm.{$em}_entity_manager");
         $this->dbal = $this->em->getConnection();
     }
     if (is_array($em)) {
         $this->em = array();
         $this->dbal = array();
         foreach ($em as $d) {
             $this->em[$d] = AbstractApp::get("doctrine.orm.{$d}_entity_manager");
             $this->dbal[$d] = $this->em[$d]->getConnection();
         }
     }
     /*
      * Przestawiam domyślny język
      */
     //        try {
     //  //          niechginiee('opt');
     //  //          niechginie($input->getOption('lang'));
     //            if ($lang = $input->getOption('lang'))
     //                $this->getContainer()->parameters['locale'] = $lang;
     //        }
     //        catch (InvalidArgumentException $e) {
     //            if (strpos($e->getMessage(), ' option does not exist') !== false) {
     //                echo $e->getMessage().PHP_EOL;
     //                die("
     //  Trzeba pdmienić ścieżkę do klasy w app/console z:
     //  use Symfony\Bundle\FrameworkBundle\Console\Application;
     //  na:
     //  use Cms\BaseBundle\Classes\Application;
     //  ");
     //            }
     //        }
 }
Ejemplo n.º 11
0
 public function getService($name)
 {
     //        $service = $this->container->get(UtilArray::cascadeGet($tdata, 'mapping.service'));
     return AbstractApp::get($name);
 }
Ejemplo n.º 12
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $man = AbstractApp::get('elastic2');
     /* @var $man ElasticSearch2 */
     $man->delete($input->getOption('index'), $input->getOption('type'), $input->getOption('id'), $output);
 }
Ejemplo n.º 13
0
 public function getRootDir($bundlepath = false)
 {
     return AbstractApp::getRootDir($bundlepath);
 }
Ejemplo n.º 14
0
 public function delete($identifier, $types = array())
 {
     return AbstractApp::getDbal()->delete(static::TABLE, $identifier, $types);
 }
Ejemplo n.º 15
0
 /**
  * Podawać tylko dla dbal.
  *
  * @param false|EntityManager $em
  */
 public function __construct($em = null)
 {
     if (is_string($em)) {
         $em = AbstractApp::get($em);
         if ($em instanceof Connection) {
             $em = EntityManager::create($em, Setup::createAnnotationMetadataConfiguration(array(), false));
         }
     }
     $this->setEM($em);
 }
Ejemplo n.º 16
0
 public function getSource($name)
 {
     niechginie('jest');
     if (AbstractApp::isDev()) {
         return $this->_replaceAssets(parent::getSource($name));
     }
     return parent::getSource($name);
     //        if ($this->isExc($name)) {
     //            return $this->_replaceAssets(parent::getSource($name));
     //        }
     //
     //        $name = $this->transform($name);
     //
     //        if (strpos($name, "\n") !== false) {
     //            return $this->_replaceAssets($name);
     //        }
     //
     //        try {
     //            return $this->_replaceAssets(parent::getSource($name));
     //    //      return parent::getSource($name.$this->checkExt($name));
     //        } catch (Twig_Error_Loader $e) {
     //            //Always response is outdated
     //            return $this->_replaceAssets($name);
     //        }
 }
Ejemplo n.º 17
0
 public function generateSlug($table, $column, $title, $dbal = 'default')
 {
     $slug = Urlizer::urlizeTrim($title);
     $dbal = AbstractApp::getDbal($dbal);
     $stmt = $dbal->prepare("SELECT count(*) c FROM {$table} WHERE {$column} = :slug");
     $i = 0;
     do {
         if ($i) {
             $slug = UtilString::incrementString($slug, '-', 1);
         }
         ++$i;
         $stmt->bindValue('slug', $slug);
         $stmt->execute();
         $row = $stmt->fetch(PDO::FETCH_ASSOC);
     } while ($row['c']);
     return $slug;
 }