Beispiel #1
0
 public function __construct(array $config, Build $builder)
 {
     $collections = new Generate\Collections($config['files'], $this);
     self::$cdir = $config['loader'];
     $namespace = "ActiveMongo2\\Namspace" . uniqid(true);
     $rnd = uniqid();
     $valns = $collections->getValidatorNS();
     $validator = $collections->getValidator();
     class_exists("crodas\\FileUtil\\File");
     // preload class
     $args = compact('docs', 'namespace', 'mapper', 'indexes', 'self', 'collections', 'valns', 'rnd', 'validator');
     $code = Template\Templates::get('documents')->render($args, true);
     if (strlen($code) >= 1024 * 1024 || !class_exists('crodas\\SimpleView\\FixCode')) {
         File::write($config['loader'], $code);
     } else {
         File::write($config['loader'], FixCode::fix($code));
     }
     $this->writeFileWatch($builder, $collections);
 }
Beispiel #2
0
 public function __construct(Configuration $config, Watch $watcher)
 {
     $this->config = $config;
     $collections = new Generate\Collections((array) $config->getModelPath(), $this);
     $this->fixPath($collections);
     $target = $config->getLoader();
     $namespace = "ActiveMongo2\\Namspace" . uniqid(true);
     $rnd = uniqid();
     $valns = $collections->getValidatorNS();
     $validator = $collections->getValidator();
     class_exists("agpmedia\\FileUtil\\File");
     // preload class
     $args = compact('docs', 'namespace', 'mapper', 'indexes', 'self', 'collections', 'valns', 'rnd', 'validator');
     $code = Template\Templates::get('documents')->render($args, true);
     if (strlen($code) >= 1024 * 1024) {
         File::write($target, $code);
     } else {
         File::write($target, FixCode::fix($code));
     }
     $this->writeFileWatch($watcher, $collections);
 }
Beispiel #3
0
 public function toCode($prop, $var = '$doc')
 {
     $self = $this;
     $args = (array) $prop->annotation->getOne($this->name);
     return Templates::get('callback')->render(compact('args', 'prop', 'self', 'var'), true);
 }