示例#1
0
    /**
     * @return string
     */
    protected function buildAutoPrepend()
    {
        $template = <<<'PHP'
<?php

namespace Psc;
use Psc\Boot\BootLoader;

require 'package.boot.php';
$bootLoader = new BootLoader(__DIR__);
$bootLoader->loadComposer();
$bootLoader->registerCMSContainer();

PSC::getProject()
  ->setStaging(%staging%)
  ->bootstrap()
%modules%
  ->getConfiguration()->set(array('url','base'), '%baseUrl%');
;

?>
PHP;
        $vars = array('staging' => $this->targetProject->isStaging() ? 'TRUE' : 'FALSE', 'projectMode' => '\\Psc\\CMS\\Project::MODE_SRC', 'projectName' => $this->targetProject->getName(), 'baseUrl' => $this->baseUrl, 'composer' => $this->composerAutoLoading ? "require_once \$bootLoader->getPath('../src/vendor/', BootLoader::RELATIVE | BootLoader::VALIDATE).'autoload.php';\n" : NULL);
        $vars['modules'] = $vars['phars'] = NULL;
        foreach ($this->modules as $moduleName) {
            $vars['modules'] .= sprintf("    ->getModule('%s')->bootstrap()->getProject()\n", $moduleName);
            if (!$this->composerAutoLoading) {
                $vars['phars'] .= sprintf('$bootLoader->getAutoLoader()->addPhar($bootLoader->getPhar(\'%s\'));' . "\n", mb_strtolower($moduleName));
            }
        }
        return \Psc\TPL\TPL::miniTemplate($template, $vars);
    }
 protected function injectToSetter(GClass $gClass)
 {
     $setter = 'set' . $this->relation->getSourceMethodName();
     if (!$gClass->hasOwnMethod($setter)) {
         throw new \RuntimeException('in der Klasse kann ' . $setter . ' nicht gefunden werden. Womöglich muss der Setter vererbt werden');
     } else {
         $setter = $gClass->getMethod($setter);
     }
     if ($this->relation->isTargetNullable()) {
         $firstParam = current($setter->getParameters());
         $firstParam->setOptional(TRUE)->setDefault(NULL);
     }
     if ($this->relation->shouldUpdateOtherSide()) {
         // wenn die Relation bidrektional ist muss der normale setter auf der Inverse side addXXX auf der aufrufen
         // das ist aber gar nicht so trivial, weil wie wird removed?
         // before('return $this').insert(...)
         $body = $setter->getBodyCode();
         $lastLine = array_pop($body);
         if (\Psc\Preg::match($lastLine, '/^\\s*return \\$this;$/') <= 0) {
             throw new \Psc\Exception('EntityRelationInterfaceBuilder möchte den Setter: ' . $setter->getName() . ' für ' . $gClass . ' ergänzen, aber der Body code scheint kein autoGenererierter zu sein.');
         }
         $body[] = \Psc\TPL\TPL::miniTemplate(($this->relation->isTargetNullable() ? 'if (isset($%paramName%)) ' : NULL) . '$%paramName%->add%otherMethodName%($this);' . "\n", array('paramName' => $this->relation->getTarget()->getParamName(), 'otherMethodName' => $this->relation->getSource()->getMethodName('singular')));
         $body[] = $lastLine;
         $setter->setBodyCode($body);
     }
 }
示例#3
0
 /**
  * @return string
  */
 public function JS()
 {
     $code = $this->getCode();
     if (is_string($code)) {
         $code = array($code);
         // blöde interfaces vom js helper
     } elseif ($code instanceof \Psc\JS\Expression) {
         $code = array($code->JS());
     }
     // load-wrappers (von innen nach außen)
     if ($this->onPscReady === 'main') {
         // non blocking mode (is save to use in html inline scripts directly)
         $this->unshiftRequirement('app/main');
         $this->unshiftRequirementAlias('main');
         $this->unshiftRequirement('jquery');
         $this->unshiftRequirementAlias('jQuery');
         $code = Helper::bootLoad($this->getRequirements(), $this->requirementsAliases, $code);
     } elseif ($this->onPscReady) {
         // is only save to use in ajax requests / inline scripts where window.requireLoad is already defined
         $this->unshiftRequirement('jquery');
         $this->unshiftRequirementAlias('jQuery');
         $code = Helper::requireLoad($this->getRequirements(), $this->requirementsAliases, $code);
     } elseif (count($req = $this->getRequirements()) > 0) {
         $code = Helper::requirejs($req, array(), $code);
     } else {
         $code = count($code) > 1 ? \Webforge\Common\ArrayUtil::join($code, "%s\n") : current($code);
     }
     return TPL::miniTemplate((string) $code, (array) $this->vars);
 }
示例#4
0
 public function loginform($ident = NULL, $permanent = FALSE)
 {
     $html = $this->htmlPage ?: new \Psc\CMS\HTMLPage();
     $formAction = $this->getTodoURL(self::TODO_LOGIN);
     $redirect = $this->getRedirect();
     $errors = $this->errors;
     $html->body->content = TPL::get(array('CMS', 'loginform'), compact('formAction', 'errors', 'ident', 'permanent', 'html', 'redirect'));
     print $html->getHTML();
 }
示例#5
0
 protected function sync()
 {
     $unison = $this->unisonBinary . ' -batch -terse ';
     $unison .= \Psc\TPL\TPL::miniTemplate('%profile% ', array('profile' => $this->profile));
     //print 'running: '.$unison."\n";
     $envs = array();
     $inherits = array('UNISON', 'HOME', 'PATH', 'SystemRoot', 'LOCALAPPDATA', 'SystemDrive', 'SSH_AUTH_SOCK', 'CommonProgramFiles', 'APPDATA', 'COMPUTERNAME', 'TEMP', 'TMP', 'USERNAME');
     foreach ($inherits as $inherit) {
         $envs[$inherit] = getenv($inherit);
     }
     $process = new Process($unison, NULL, $envs);
     $process->setTimeout(0);
     $log = NULL;
     $result = new \stdClass();
     $resultFound = FALSE;
     $ret = $process->run(function ($type, $buffer) use(&$log, &$result, &$resultFound) {
         // suche nach dem endergebnis:
         $m = array();
         if (\Psc\Preg::match($buffer, '/^Synchronization\\s*complete\\s*at\\s*[0-9:]*\\s*\\(([0-9]+)\\s*items?\\s*transferred, ([0-9]+) skipped,\\s*([0-9]+)\\s*failed\\)/i', $m)) {
             $resultFound = TRUE;
             $result = (object) array('transferred' => (int) $m[1], 'skipped' => (int) $m[2], 'failed' => (int) $m[3]);
         }
         $log .= $buffer;
         //if ('err' === $type) {
         //    echo '[unison-ERR]: '.$buffer;
         //} else {
         //    echo '[unison-OUT]: '.$buffer;
         //}
     });
     print "\n";
     if ($resultFound) {
         print sprintf("Unison: (%d transferred, %d skipped, %d failed)\n", $result->transferred, $result->skipped, $result->failed);
     }
     // http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#exit
     switch ($ret) {
         case 0:
             print 'Unison: successful synchronization';
             break;
         case 1:
             print 'Unison: some files were skipped, but all file transfers were successful.';
             break;
         case 2:
             print 'Unison: non-fatal failures occurred during file transfer.';
             break;
         case 3:
             print 'Unison: a fatal error occurred, or the execution was interrupted.';
             break;
         default:
             print 'Unison: unknown exit code: ' . $ret;
             break;
     }
     print "\n";
     if ($ret !== 0) {
         throw new RuntimeException('Unison failed: ' . $log);
     }
 }
示例#6
0
 public function write()
 {
     $contents = TPL::miniTemplate($this->miniTemplate, array('index' => Writer::variable(array('log', 'index'), $this->index), 'data' => Writer::variable(array('log', 'data'), $this->data)));
     $dir = $this->file->getDirectory();
     if (!$dir->exists()) {
         $dir->make('-p');
     }
     $this->file->writeContents($contents, File::EXCLUSIVE);
     return $this;
 }
示例#7
0
 /**
  * @param mixed $value
  */
 public function toString($value, Type $type = NULL)
 {
     if (isset($type)) {
         // wenn wir den typ checken statt der value geht auch (int) $timestamp, new DateTimeType()
         // das ist cooler
         if ($type instanceof Types\DateTimeType) {
             if ($value) {
                 return $value->i18n_format($this->dateTimeFormat);
             }
         }
         if ($type instanceof Types\DateType) {
             if ($value) {
                 return $value->i18n_format($this->dateFormat);
             }
         }
         if ($type instanceof Types\EntityType && $value != NULL) {
             return $value->getContextLabel();
         }
         $that = $this;
         if ($type instanceof Types\CollectionType) {
             return \Psc\FE\Helper::listObjects($value, ', ', function ($innerValue) use($that, $type) {
                 // ersetzt den getter
                 try {
                     return $that->toString($innerValue, $type->getType());
                 } catch (NotTypedException $e) {
                     // was tun wenn wir den inner type nicht kennen?
                     return $that->toString($innerValue);
                 }
             });
         }
         if ($type instanceof Types\I18nType) {
             return \Psc\FE\Helper::listObjects($value, "<br />", function ($innerValue, $key) use($that, $type) {
                 // ersetzt den getter
                 try {
                     return '[' . $key . '] ' . $that->toString($innerValue, $type->getType());
                 } catch (NotTypedException $e) {
                     // was tun wenn wir den inner type nicht kennen?
                     return $that->toString($innerValue);
                 }
             });
         }
         if ($type instanceof Types\BooleanType) {
             if ($value == TRUE) {
                 return '<span class="ui-icon ui-icon-check"></span>';
             } else {
                 return '';
             }
         }
         if ($type instanceof Types\MarkupTextType) {
             return TPL::MiniMarkup($value);
         }
     }
     return (string) $value;
 }
示例#8
0
 /**
  * Der Text aller Paragraphen innerhalb von allen Sections, die als Style '([a-zA-Z0-9]*).template' haben werden mit diesen Variablen ersetzt
  *
  * letz get dirty:
  * für diesen Hack muss in PHPWord_Section_Text setText() definiert sein
  */
 public function miniTemplateReplace(array $vars)
 {
     foreach ($this->word->getSections() as $section) {
         foreach ($section->getElements() as $element) {
             if ($element instanceof \PHPWord_Section_Text) {
                 $style = $element->getParagraphStyle();
                 if (is_string($style) && mb_strpos($style, '.template') !== FALSE && ($text = $element->getText()) && mb_strpos($text, '%') !== FALSE) {
                     $element->setText(TPL::miniTemplate($text, $vars));
                 }
             }
         }
     }
 }
示例#9
0
    public function run()
    {
        if (!isset($this->changes) || !is_array($this->changes)) {
            throw new \InvalidArgumentException('changes muss gesetzt sein');
        }
        if (!$this->changelog->exists()) {
            throw new \RuntimeException('changelogFile ' . $targetFile . ' muss existieren');
        }
        require $this->changelog;
        /* changeslist : 
           
           'bugfix: Im Sound Content stand nur "content" statt dem eigentlichen Soundtext',
           'geändert: Bei der Soundsuche wird bei sehr großen Results das Ergebnis auf 15 Einträge eingeschränkt'
           
           */
        /* version */
        //2.0.9-Beta
        $version = \Psc\Preg::qmatch($data[0]['version'], '/^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\-(Alpha|Beta|Gamma)$/i', array(1, 2, 3, 4));
        if (!is_array($version)) {
            throw new \RuntimeException('Fehler beim Version Parsing. Alte Version ' . $oldVersion);
        }
        if ($this->versionIncrement === 'minor') {
            $version[2]++;
        } else {
            throw new \InvalidArgumentException('Kann nichts anderes als minor für versionIncrement');
        }
        $newVersion = vsprintf('%d.%d.%d-%s', $version);
        $php = <<<'PHP'
$data[] = array(
  'version'=>'%version%',
  'time'=>'%time%',
  'changelog'=>array(
    %changesList%
  )
);

PHP;
        $php = \Psc\TPL\TPL::miniTemplate($php, array('version' => $newVersion, 'time' => date('H:i d.m.Y'), 'changesList' => \Webforge\Common\ArrayUtil::implode($this->changes, ",\n    ", function ($change) {
            return var_export($change, true);
        })));
        $contents = $this->changelog->getContents();
        $pos = mb_strpos($contents, $needle = '$data = array();' . "\n");
        if ($pos === FALSE) {
            throw new \RuntimeException('Cannot Modify File: ' . \Webforge\Common\String::cutAt($contents, 300) . ' enhält nicht ' . $needle);
        }
        $pos += mb_strlen($needle);
        $contents = mb_substr($contents, 0, $pos) . $php . "\n" . mb_substr($contents, $pos);
        $this->changelog->writeContents($contents);
    }
示例#10
0
 public function getWelcomeTemplate()
 {
     if (!isset($this->welcomeTemplate)) {
         $translator = $this->getTranslator();
         $tpl = $this->welcomeTemplate = new Template('welcome');
         $this->welcomeTemplate->setVar('cms', $this);
         $this->welcomeTemplate->setVar('project', $this->getProject());
         $this->welcomeTemplate->setVar('main', $this);
         $this->welcomeTemplate->setLanguage($this->getLanguage());
         $this->welcomeTemplate->setVar('trans', function ($key, array $parameters = array()) use($tpl, $translator) {
             return $translator->trans($key, $parameters, 'cms');
         });
         $this->welcomeTemplate->mergeI18n(array('de' => array('title' => $translator->trans('welcome.tabTitle', array(), 'cms', 'de')), 'en' => array('title' => $translator->trans('welcome.tabTitle', array(), 'cms', 'en')), 'fr' => array('title' => $translator->trans('welcome.tabTitle', array(), 'cms', 'fr'))));
     }
     return $this->welcomeTemplate;
 }
示例#11
0
 /**
  * Gibt das HTML für die AssociationList zurück
  *
  * ist $assoc->limit angegeben und ist die anzahl der entities größer als diess wird $assoc->limitMessage zurückgegeben
  * sind keine Entities zu finden, wird $assoc->emptyText zurückgegeben
  * ansonsten wird für jedes Entities $assoc.withLabel oder ein button erzeugt (withButton(TRUE))
  */
 public function getHTMLForList(AssociationList $assoc)
 {
     if (!isset($this->entity)) {
         throw new \RuntimeException('Entity muss gesetzt sein, wenn html() oder init() aufgerufen wird');
     }
     $entities = $this->getAssocEntities($assoc);
     // die collection, ist klar
     if (($sorter = $assoc->getSortBy()) != NULL) {
         $entities = $sorter($entities);
     }
     $cnt = count($entities);
     if ($cnt > 0) {
         if ($assoc->hasLimit() && $cnt > $assoc->getLimit()) {
             return sprintf($assoc->getLimitMessage(), $cnt);
         } else {
             $html = h::listObjects($entities, $assoc->getJoinedWith(), $assoc->getWithButton() ? $this->getHTMLButtonClosure() : $assoc->getWithLabel(), $assoc->getAndJoiner());
         }
         return \Psc\TPL\TPL::miniTemplate($assoc->getFormat(), array('list' => $html));
     } else {
         return $assoc->getEmptyText();
     }
 }
    /**
     * @return string
     */
    protected function buildBootstrap()
    {
        $template = <<<'PHP'
<?php
/**
 * Bootstrap and Autoload whole application
 *
 * you can use this file to bootstrap for tests or bootstrap for scripts / others
 */
$ds = DIRECTORY_SEPARATOR;

// autoload project dependencies and self autoloading for the library
require_once __DIR__.$ds.'vendor'.$ds.'autoload.php';

// autoload psc-cms
require_once __DIR__.$ds.'vendor'.$ds.'pscheit'.$ds.'psc-cms'.$ds.'bin'.$ds.'psc-cms.phar.gz';

return $GLOBALS['env']['root'] = new \Webforge\Common\System\Dir(__DIR__.DIRECTORY_SEPARATOR);
?>
PHP;
        return \Psc\TPL\TPL::miniTemplate($template, array());
    }
示例#13
0
 public function persist(Storage $storage)
 {
     $this->file->writeContents(\Psc\TPL\TPL::miniTemplate($this->template, array('dataPHP' => '$data = ' . var_export($storage->getData()->getData(), TRUE) . ';')), File::EXCLUSIVE);
     return $this;
 }
示例#14
0
 public function getMailText()
 {
     $mailText = $this->template;
     $mailText = TPL::miniTemplate($mailText, $this->data->getFields()->toArray());
     return $mailText;
 }
示例#15
0
 protected function replaceHelpers($string)
 {
     $vhost = $this->vhostName;
     return TPL::miniTemplate($string, array('vhost' => '/var/local/www/' . $vhost . '/', 'documentRoot' => $this->documentRoot, 'documentRootCms' => $this->documentRootCms, 'serverName' => $this->serverName));
 }
示例#16
0
 /**
  * @return array
  */
 protected function createCode($type, array $vars)
 {
     if ($type === 'getter') {
         $code = array('return $this->%property%;');
     } elseif ($type === 'setter') {
         $code = array('$this->%property% = $%property%;', 'return $this;');
     } elseif ($type === 'constructorSetterPart') {
         $code = array('$this->%setter%($%property%);');
     } elseif ($type === 'constructorSetterPartOptional') {
         $code = array('if (isset($%property%)) {', '  $this->%setter%($%property%);', '}');
     }
     return explode("\n", TPL::miniTemplate(implode("\n", $code), $vars));
 }
示例#17
0
    protected function compileClosure(GMethod $method, $closureName)
    {
        // wir erzeugen sowas hier (ohne semikolon am ende)
        /*
          parameter von $funcName sind $name und $type
         
          $funcName = function ($name, $type) use ($that) {
            return $that->funcName($name, $type);
          }
        */
        $code = <<<'PHP'
$%closureName% = function (%parameters%) use ($that) {
  return $that->%method%(%callParameters%);
}
PHP;
        $codeWithFuncArgs = <<<'PHP'
$%closureName% = function () use ($that) {
  return call_user_func_array(array($that, '%method%'), func_get_args());
}
PHP;
        // wenn die innere funktion func_get_args() benutzt, müssen wir call_user_func nehmen ($codeWithFuncArgs)
        if (mb_strpos($method->getBody(), 'func_get_args()')) {
            // das ist natürlich nicht so schön als entscheidung, aber false positive macht nichts (außer bissl performance)
            $code = $codeWithFuncArgs;
            $parameters = $callParameters = NULL;
        } else {
            // kopiert von GFunction
            $parameters = \Webforge\Common\ArrayUtil::implode($method->getParameters(), ', ', function ($parameter) {
                return $parameter->php($useFQNHints = TRUE);
            });
            $callParameters = \Webforge\Common\ArrayUtil::implode($method->getParameters(), ', ', function ($parameter) {
                // für die 2ten parameter entfernen wir alle hints, damit wir nur die parameter auflistungen haben
                $parameter = clone $parameter;
                $parameter->setHint(NULL);
                $parameter->setArray(FALSE);
                $parameter->setDefault(GParameter::UNDEFINED);
                return $parameter->php();
            });
        }
        $code = \Psc\TPL\TPL::miniTemplate($code, array('parameters' => $parameters, 'callParameters' => $callParameters, 'method' => $method->getName(), 'closureName' => $closureName));
        return $code;
    }
示例#18
0
 public function addMarkup(\Psc\HTML\Page $page, array $vars = array())
 {
     $translator = $this->getContainer()->getTranslationContainer()->getTranslator();
     $page->body->content = TPL::get(array('CMS', 'main'), array_merge(array('page' => $page, 'authController' => $this->getAuthController(), 'user' => $this->getUser(), 'tabs' => $this->getContentTabs(), 'main' => $this, 'trans' => function ($key, array $parameters = array()) use($translator) {
         return $translator->trans($key, $parameters, 'cms');
     }, 'cms' => $this), $vars));
 }
示例#19
0
    $fields = array();
    if ($extension->hasMethod('__construct')) {
        foreach ($extension->getMethod('__construct')->getParameters() as $param) {
            $fields[] = $param->getName();
        }
    }
    // das nimmt vielleicht zu viele, weis nicht, alternativ würds auch ne statische methode zur extension tun
    foreach ($extension->getProperties() as $property) {
        $fields[] = $property->getName();
    }
    $json = array();
    foreach (array_unique($fields) as $field) {
        $json[$field] = '%(ask:' . $field . ')';
    }
    $command->comment(sprintf('Komodo-Command für %s:', $extension->getClassName()));
    $output->writeln(\Psc\TPL\TPL::miniTemplate('cli.bat compile:generic %F inFile %extension% %json%', array('extension' => $extension->getClassName(), 'json' => json_encode((object) $json))));
});
$createCommand('git:pre-push-hook', array($arg('someFile'), $arg('someFile2'), $arg('workingTree')), function ($input, $output, $command) {
    $workingTree = Dir::factoryTS($input->getArgument('workingTree'));
    $dir = new Dir(__DIR__ . DIRECTORY_SEPARATOR);
    $root = $dir->up();
    if ($workingTree->equals($root)) {
        $dist = $root->getFile('dist/psc-cms.phar.gz');
        $lastMessage = exec('git log -n 1 --format=%s');
        $updateComposer = 'composer update --prefer-dist --dev';
        $buildPhar = $root->getFile('bin/cli') . ' build-phar';
        $cd = 'cd ' . $root;
        $ammend = 'git commit -m"' . $lastMessage . '" --amend -o ' . $dist . ' composer.lock ';
        system($cd . ' && ' . $updateComposer . ' && ' . $buildPhar . ' && ' . $ammend);
        return 0;
    }
示例#20
0
 /**
  * @dataProvider provideBUIMarkupText
  */
 public function testBUIMarkup($expectedHTML, $text)
 {
     $this->assertEquals($expectedHTML, TPL::replaceBUIMarkup($text));
 }
示例#21
0
 protected function buildCLI()
 {
     $vars = array('project' => $this->targetProject->getName(), 'projectConsole' => '\\' . $this->targetProject->getNamespace() . ($this->targetProject->loadedFromPackage ? '\\CMS' : '') . '\\ProjectConsole', 'autoPrependFile' => $this->autoPrependFile);
     $this->targetProject->getBin()->getFile('cli.php')->writeContents(\Psc\TPL\TPL::miniTemplate($this->cliPHPTemplate, $vars));
 }
示例#22
0
 public function generatePHP(array $imports = array())
 {
     if (!isset($this->gClass)) {
         throw new ClassWritingException('Klasse nicht gesetzt. (zuerst setClass() dann write().');
     }
     $use = NULL;
     /* merge mit params */
     foreach ($imports as $iClass) {
         $alias = NULL;
         if (is_array($iClass)) {
             list($iClass, $alias) = $iClass;
         }
         if (!$iClass instanceof GClass) {
             throw new \Psc\Exception('Imports können nur vom typ GClass sein');
         }
         $this->addImport($iClass, $alias);
     }
     if (count($this->foundImports) > 0) {
         $useImports = array();
         foreach ($this->foundImports as $alias => $gClass) {
             // wir filten nach den imports, die im selben Namespace sind und keinen besonderen Alias haben
             if ($alias !== $gClass->getClassName() || $gClass->getNamespace() !== $this->gClass->getNamespace()) {
                 $useImports[$alias] = $gClass;
             }
         }
         /* Render PHP */
         $classAlias = function ($gClass, $alias) {
             if ($alias === $gClass->getClassName()) {
                 return $gClass->getFQN();
             } else {
                 return $gClass->getFQN() . ' AS ' . $alias;
             }
         };
         if (count($useImports) > 0) {
             $use .= "\n";
             // abstand zu namespace (neue Zeile)
             if ($this->useStyle === self::USE_STYLE_LINES) {
                 $use .= A::joinc($useImports, "use %s;\n", $classAlias);
             } else {
                 $use .= 'use ' . A::implode($useImports, ",\n    ", $classAlias);
                 $use .= ';';
                 $use .= "\n";
                 // abstand zu class (neue Zeile)
             }
         }
     }
     $php = TPL::miniTemplate($this->template, array('class' => $this->gClass->php(), 'use' => $use, 'namespace' => $this->gClass->getNamespace() != NULL ? 'namespace ' . ltrim($this->gClass->getNamespace(), '\\') . ';' : NULL));
     return $php;
 }
 protected function getImplementation($type)
 {
     if (!isset($this->implementations)) {
         $this->implementations['Array'] = array('itemGetter' => array('return array_key_exists($key, $this->%collection%) ? $this->%collection%[$key] : NULL;'), 'itemAdder' => array('$this->%collection%[] = $%item%;', 'return $this;'), 'itemChecker' => array('return in_array($%item%, $this->%collection%);'), 'itemRemover' => array('if (($key = array_search($%item%, $this->%collection%, %strict%)) !== FALSE) {', '  array_splice($this->%collection%, $key, 1);', '}', 'return $this;'));
         $this->implementations['Collection'] = array('itemGetter' => array('return $this->%collection%->containsKey($key, $this->%collection%) ? $this->%collection%->get($key) : NULL;'), 'itemAdder' => array('$this->%collection%->add($%item%);', 'return $this;'), 'itemChecker' => array('return $this->%collection%->contains($%item%);'), 'itemRemover' => array('if ($this->contains($%item%)) {', '  $this->removeElement($%item%);', '}', 'return $this;'));
     }
     $vars = $this->codeVars;
     $code = array_map(function ($line) use($vars) {
         return \Psc\TPL\TPL::miniTemplate($line, $vars);
     }, $this->implementations[$this->collectionType->getName()][$type]);
     return $code;
 }