original_string: private function generateRepository($className) {
  		$table = EntityReflexion::getTable($className);
  		if ($table === NULL) {
  			throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
  		} else {
  			$genClassName = $this->generateRepositoryName($className);
  			if (!class_exists($genClassName)) {
  				$class = $this->cache->load($genClassName);
  				if ($class) {
  					$repository = $class;
  				} else {
  					$repository = new ClassType($genClassName);
  					$repository->addExtend('\slimORM\BaseRepository');
  					$repository->setFinal(TRUE);
  					$repository->addComment($genClassName);
  					$repository->addComment("@generated");
  					$repository->addProperty("connection")
  						->setVisibility("protected")
  						->addComment('@var \Nette\Database\Context');
  					$repository->addProperty("entityManager")
  						->setVisibility("protected")
  						->addComment('@var \slimORM\EntityManager');
  					$parameter = new Parameter("connection");
  					$parameter->setTypeHint('\Nette\Database\Context');
  					$parameter2 = new Parameter("entityManager");
  					$parameter2->setTypeHint('\slimORM\EntityManager');
  					$entity = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
  					$repository->addMethod("__construct")
  						->addComment($genClassName . " constructor")
  						->addComment('@param \Nette\Database\Context $connection')
  						->addComment('@param \slimORM\EntityManager $entityManager')
  						->setParameters(array($parameter, $parameter2))
  						->setBody("\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");");
  					$parameter = new Parameter("key");
  					$repository->addMethod("get")
  						->addComment("Find item by primary key")
  						->addComment("@param int \$key")
  						->addComment("@return $entity|null")
  						->setParameters(array($parameter))
  						->setBody("return parent::get(\$key);");
  
  					//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
  					$this->cache->save($genClassName, $repository, array(
  						Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
  					));
  				}
  				$res = eval('?><?php ' . $repository);
  				if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
  					throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
  				}
  				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
  			} else if (!isset($this->repositories[$genClassName])) {
  				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
  			}
  		}
  	}
code: private function generateRepository($className) {
  		$table = EntityReflexion::getTable($className);
  		if ($table === NULL) {
  			throw new RepositoryException("Entity \"" . $className . " has no annotation \"table\"");
  		} else {
  			$genClassName = $this->generateRepositoryName($className);
  			if (!class_exists($genClassName)) {
  				$class = $this->cache->load($genClassName);
  				if ($class) {
  					$repository = $class;
  				} else {
  					$repository = new ClassType($genClassName);
  					$repository->addExtend('\slimORM\BaseRepository');
  					$repository->setFinal(TRUE);
  					$repository->addComment($genClassName);
  					$repository->addComment("@generated");
  					$repository->addProperty("connection")
  						->setVisibility("protected")
  						->addComment('@var \Nette\Database\Context');
  					$repository->addProperty("entityManager")
  						->setVisibility("protected")
  						->addComment('@var \slimORM\EntityManager');
  					$parameter = new Parameter("connection");
  					$parameter->setTypeHint('\Nette\Database\Context');
  					$parameter2 = new Parameter("entityManager");
  					$parameter2->setTypeHint('\slimORM\EntityManager');
  					$entity = EntityManager::PREFIX . str_replace("\\", "", $className) . "Entity";
  					$repository->addMethod("__construct")
  						->addComment($genClassName . " constructor")
  						->addComment('@param \Nette\Database\Context $connection')
  						->addComment('@param \slimORM\EntityManager $entityManager')
  						->setParameters(array($parameter, $parameter2))
  						->setBody("\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");");
  					$parameter = new Parameter("key");
  					$repository->addMethod("get")
  						->addComment("Find item by primary key")
  						->addComment("@param int \$key")
  						->addComment("@return $entity|null")
  						->setParameters(array($parameter))
  						->setBody("return parent::get(\$key);");
  
  					//FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository);
  					$this->cache->save($genClassName, $repository, array(
  						Cache::FILES => EntityReflexion::getFile($className), // lze uvést i pole souborů
  					));
  				}
  				$res = eval('?><?php ' . $repository);
  				if ($res === FALSE && ($error = error_get_last()) && $error['type'] === E_PARSE) {
  					throw new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']);
  				}
  				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
  			} else if (!isset($this->repositories[$genClassName])) {
  				$this->repositories[$genClassName] = new $genClassName($this->connection, $this);
  			}
  		}
  	}
code_tokens: private function generateRepository ( $ className ) { $ table = EntityReflexion :: getTable ( $ className ) ; if ( $ table === NULL ) { throw new RepositoryException ( "Entity \"" . $ className . " has no annotation \"table\"" ) ; } else { $ genClassName = $ this -> generateRepositoryName ( $ className ) ; if ( ! class_exists ( $ genClassName ) ) { $ class = $ this -> cache -> load ( $ genClassName ) ; if ( $ class ) { $ repository = $ class ; } else { $ repository = new ClassType ( $ genClassName ) ; $ repository -> addExtend ( '\slimORM\BaseRepository' ) ; $ repository -> setFinal ( TRUE ) ; $ repository -> addComment ( $ genClassName ) ; $ repository -> addComment ( "@generated" ) ; $ repository -> addProperty ( "connection" ) -> setVisibility ( "protected" ) -> addComment ( '@var \Nette\Database\Context' ) ; $ repository -> addProperty ( "entityManager" ) -> setVisibility ( "protected" ) -> addComment ( '@var \slimORM\EntityManager' ) ; $ parameter = new Parameter ( "connection" ) ; $ parameter -> setTypeHint ( '\Nette\Database\Context' ) ; $ parameter2 = new Parameter ( "entityManager" ) ; $ parameter2 -> setTypeHint ( '\slimORM\EntityManager' ) ; $ entity = EntityManager :: PREFIX . str_replace ( "\\" , "" , $ className ) . "Entity" ; $ repository -> addMethod ( "__construct" ) -> addComment ( $ genClassName . " constructor" ) -> addComment ( '@param \Nette\Database\Context $connection' ) -> addComment ( '@param \slimORM\EntityManager $entityManager' ) -> setParameters ( array ( $ parameter , $ parameter2 ) ) -> setBody ( "\$this->connection = \$connection;\n\$this->entityManager = \$entityManager;\nparent::__construct(\$connection, \"$table\", \"$entity\");" ) ; $ parameter = new Parameter ( "key" ) ; $ repository -> addMethod ( "get" ) -> addComment ( "Find item by primary key" ) -> addComment ( "@param int \$key" ) -> addComment ( "@return $entity|null" ) -> setParameters ( array ( $ parameter ) ) -> setBody ( "return parent::get(\$key);" ) ; //FileSystem::write(WWW_DIR . '/temp/' . $genClassName . ".php", "<?php\n" . $repository); $ this -> cache -> save ( $ genClassName , $ repository , array ( Cache :: FILES => EntityReflexion :: getFile ( $ className ) , // lze uvést i pole souborů ) ) ; } $ res = eval ( '?><?php ' . $ repository ) ; if ( $ res === FALSE && ( $ error = error_get_last ( ) ) && $ error [ 'type' ] === E_PARSE ) { throw new \ ErrorException ( $ error [ 'message' ] , 0 , $ error [ 'type' ] , $ error [ 'file' ] , $ error [ 'line' ] ) ; } $ this -> repositories [ $ genClassName ] = new $ genClassName ( $ this -> connection , $ this ) ; } else if ( ! isset ( $ this -> repositories [ $ genClassName ] ) ) { $ this -> repositories [ $ genClassName ] = new $ genClassName ( $ this -> connection , $ this ) ; } } }
docstring: Generate repository class
  @param $className
  @throws RepositoryException
  @throws \ErrorException
docstring_tokens: Generate repository class