Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions zmc/EntityCreatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ private function _setPrimaryKey($primary_key) {
private function _generateClassHeader($className) {
$this->_data .= "<?php
/**
* file: " . ucfirst(strtolower($className)) . ".php
* " . ucfirst(strtolower($className)) . " entity
* file: " . $className . ".php
* " . $className . " entity
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
Expand All @@ -62,15 +62,15 @@ private function _generateClassHeader($className) {
namespace ".ZendModelCreator::getNamespace()."\Entity;

/**
* " . ucfirst(strtolower($className)) . "
* " . $className . "
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
* @package ".ZendModelCreator::getNamespace()."
* @since " . date("Y-m-d") . "
*
**/
class " . ucfirst(strtolower($className)) . "
class " . $className . "
{
";
}
Expand Down
22 changes: 11 additions & 11 deletions zmc/EventCreatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function createEventService($className, $parameterArray) {
private function _generateClassHeader($className) {
$this->_data .= "<?php
/**
* file: " . ucfirst(strtolower($className)) . "Event.php
* " . ucfirst(strtolower($className)) . " Event
* file: " . $className . "Event.php
* " . $className . " Event
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
Expand All @@ -52,15 +52,15 @@ private function _generateClassHeader($className) {
use Zend\EventManager\Event;

/**
* " . ucfirst(strtolower($className)) . "Event
* " . $className . "Event
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
* @package ".ZendModelCreator::getNamespace()."
* @since " . date("Y-m-d") . "
*
**/
class " . ucfirst(strtolower($className)) . " extends Event
class " . $className . "Event extends Event
{
";
}
Expand All @@ -69,9 +69,9 @@ class " . ucfirst(strtolower($className)) . " extends Event
* Generate constants
*/
private function _generateConstants($className) {
$this->_data.="\tconst EVENT_ADD_" . strtoupper($className) . "_POST = 'add" . ucfirst(strtolower($className)) . ".post';\n";
$this->_data.="\tconst EVENT_UPDATE_" . strtoupper($className) . "_POST = 'update" . ucfirst(strtolower($className)) . ".post';\n";
$this->_data.="\tconst EVENT_DELETE_" . strtoupper($className) . "_POST = 'delete" . ucfirst(strtolower($className)) . ".post';\n";
$this->_data.="\tconst EVENT_ADD_" . strtoupper($className) . "_POST = 'add" . $className . ".post';\n";
$this->_data.="\tconst EVENT_UPDATE_" . strtoupper($className) . "_POST = 'update" . $className . ".post';\n";
$this->_data.="\tconst EVENT_DELETE_" . strtoupper($className) . "_POST = 'delete" . $className . ".post';\n";
$this->_data.="\n";
}

Expand All @@ -83,10 +83,10 @@ private function _generateGet($className) {
$this->_data.="\t* Get record from event\n";
$this->_data.="\t*\n";
$this->_data.="\t**/\n";
$this->_data.="\tpublic function get" . ucfirst(strtolower($className)) . "()\n";
$this->_data.="\tpublic function get" . $className . "()\n";
$this->_data.="\t{\n";
$this->_data.="\t\t// Return param\n";
$this->_data.="\t\treturn \$this->getParam('" . strtolower($className) . "');\n";
$this->_data.="\t\treturn \$this->getParam('" . ZendModelCreator::fromCamelCase($className) . "');\n";
$this->_data.="\t}\n\n";
}

Expand All @@ -98,10 +98,10 @@ private function _generateSet($className) {
$this->_data.="\t* Set record to event\n";
$this->_data.="\t*\n";
$this->_data.="\t**/\n";
$this->_data.="\tpublic function set" . ucfirst(strtolower($className)) . "(" . $className . "Entity \$" . strtolower($className) . ")\n";
$this->_data.="\tpublic function set" . $className . "(" . $className . "Entity \$" . ZendModelCreator::fromCamelCase($className) . ")\n";
$this->_data.="\t{\n";
$this->_data.="\t\t// Set param\n";
$this->_data.="\t\t\$this->setParam('" . strtolower($className) . "', \$" . strtolower($className) . ");\n";
$this->_data.="\t\t\$this->setParam('" . ZendModelCreator::fromCamelCase($className) . "', \$" . ZendModelCreator::fromCamelCase($className) . ");\n";
$this->_data.="\t\treturn \$this;\n";
$this->_data.="\t}";
}
Expand Down
34 changes: 17 additions & 17 deletions zmc/MapperCreatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private function _generateClassHeader($className) {
$this->_data .= "<?php
/**
* file: ".$className."Mapper.php
* " . ucfirst(strtolower($className)) . " mapper
* " . $className . " mapper
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
Expand All @@ -71,15 +71,15 @@ private function _generateClassHeader($className) {
use ZfcBase\Mapper\AbstractDbMapper;

/**
* " . ucfirst(strtolower($className)) . "Mapper
* " . $className . "Mapper
*
* @author ".ZendModelCreator::getGenerator()."
* @version ".ZendModelCreator::getVersion()."
* @package ".ZendModelCreator::getNamespace()."
* @since " . date("Y-m-d") . "
*
**/
class " . ucfirst(strtolower($className)) . "Mapper extends AbstractDbMapper
class " . $className . "Mapper extends AbstractDbMapper
{
";
}
Expand Down Expand Up @@ -110,12 +110,12 @@ private function _generateFindById($className) {
$this->_data.="\t* Find a record by id\n";
$this->_data.="\t*\n";
$this->_data.="\t* @param int \$id\n";
$this->_data.="\t* @return object ".ZendModelCreator::getNamespace()."\Entity\\" . ucfirst(strtolower($className)) . "\n";
$this->_data.="\t* @return object ".ZendModelCreator::getNamespace()."\Entity\\" . $className . "\n";
$this->_data.="\t**/\n";
$this->_data.="\tpublic function findById(\$id)\n";
$this->_data.="\t{\n";
$this->_data.="\t\t\$select = new Select;\n";
$this->_data.="\t\t\$select->from('" . strtolower($className) . "');\n";
$this->_data.="\t\t\$select->from('" . ZendModelCreator::fromCamelCase($className) . "');\n";
$this->_data.="\t\t\$where = new Where;\n";
$this->_data.="\t\t\$where->equalTo('" . $this->_primary_key . "', \$id);\n";
$this->_data.="\t\t\$result = \$this->select(\$select->where(\$where))->current();\n";
Expand All @@ -132,12 +132,12 @@ private function _generateFindAll($className) {
$this->_data.="\t/**\n";
$this->_data.="\t* Find all records\n";
$this->_data.="\t*\n";
$this->_data.="\t* @return array objects ".ZendModelCreator::getNamespace()."\Entity\\" . ucfirst(strtolower($className)) . "\n";
$this->_data.="\t* @return array objects ".ZendModelCreator::getNamespace()."\Entity\\" . $className . "\n";
$this->_data.="\t**/\n";
$this->_data.="\tpublic function findAll()\n";
$this->_data.="\t{\n";
$this->_data.="\t\t\$select = new Select;\n";
$this->_data.="\t\t\$select->from('" . strtolower($className) . "');\n";
$this->_data.="\t\t\$select->from('" . ZendModelCreator::fromCamelCase($className) . "');\n";
$this->_data.="\t\t\$result = \$this->select(\$select);\n";
$this->_data.="\t\treturn \$result;\n";
$this->_data.="\t}\n\n";
Expand All @@ -152,20 +152,20 @@ private function _generatePersist($className) {
$this->_data.="\t/**\n";
$this->_data.="\t* Save a record\n";
$this->_data.="\t*\n";
$this->_data.="\t* @param object ".ZendModelCreator::getNamespace()."\Entity\\" . ucfirst(strtolower($className)) . "\n";
$this->_data.="\t* @return object ".ZendModelCreator::getNamespace()."\Entity\\" . ucfirst(strtolower($className)) . "\n";
$this->_data.="\t* @param object ".ZendModelCreator::getNamespace()."\Entity\\" . $className . "\n";
$this->_data.="\t* @return object ".ZendModelCreator::getNamespace()."\Entity\\" . $className . "\n";
$this->_data.="\t**/\n";
$this->_data.="\tpublic function persist(" . ucfirst(strtolower($className)) . " \$" . strtolower($className) . ")\n";
$this->_data.="\tpublic function persist(" . $className . " \$" . ZendModelCreator::fromCamelCase($className) . ")\n";
$this->_data.="\t{\n";
$this->_data.="\t\tif (\$" . strtolower($className) . "->get" . ZendModelCreator::toCamelCase($this->_primary_key) . "() > 0) {\n";
$this->_data.="\t\tif (\$" . ZendModelCreator::fromCamelCase($className) . "->get" . ZendModelCreator::toCamelCase($this->_primary_key) . "() > 0) {\n";
$this->_data.="\t\t\t\$where = new Where;\n";
$this->_data.="\t\t\t\$where->equalTo('" . $this->_primary_key . "', \$" . strtolower($className) . "->get" . ZendModelCreator::toCamelCase($this->_primary_key) . "());\n";
$this->_data.="\t\t\t\$this->update(\$" . strtolower($className) . ", \$where, '" . strtolower($className) . "');\n";
$this->_data.="\t\t\t\$where->equalTo('" . $this->_primary_key . "', \$" . ZendModelCreator::fromCamelCase($className) . "->get" . ZendModelCreator::toCamelCase($this->_primary_key) . "());\n";
$this->_data.="\t\t\t\$this->update(\$" . ZendModelCreator::fromCamelCase($className) . ", \$where, '" . ZendModelCreator::fromCamelCase($className) . "');\n";
$this->_data.="\t\t} else {\n";
$this->_data.="\t\t\t\$result = \$this->insert(\$" . strtolower($className) . ", '" . strtolower($className) . "');\n";
$this->_data.="\t\t\t\$" . strtolower($className) . "->set" . ZendModelCreator::toCamelCase($this->_primary_key) . "(\$result->getGeneratedValue());\n";
$this->_data.="\t\t\t\$result = \$this->insert(\$" . ZendModelCreator::fromCamelCase($className) . ", '" . ZendModelCreator::fromCamelCase($className) . "');\n";
$this->_data.="\t\t\t\$" . ZendModelCreator::fromCamelCase($className) . "->set" . ZendModelCreator::toCamelCase($this->_primary_key) . "(\$result->getGeneratedValue());\n";
$this->_data.="\t\t}\n";
$this->_data.="\t\treturn \$" . strtolower($className) . ";\n";
$this->_data.="\t\treturn \$" . ZendModelCreator::fromCamelCase($className) . ";\n";
$this->_data.="\t}\n\n";
}

Expand All @@ -189,7 +189,7 @@ private function _generateDelete($className) {
$this->_data.="\t\t\$where = new Where;\n";
$this->_data.="\t\t\$where->equalTo('" . $this->_primary_key . "', \$" . $this->_primary_key . ");\n";
$this->_data.="\t\t\$sql = new Delete;\n";
$this->_data.="\t\t\$sql->from('" . strtolower($className) . "')->where(\$where);\n";
$this->_data.="\t\t\$sql->from('" . ZendModelCreator::fromCamelCase($className) . "')->where(\$where);\n";
$this->_data.="\t\t\$sql->prepareStatement(\$adapter, \$statement);\n";
$this->_data.="\t\t\$result = \$statement->execute();\n";
$this->_data.="\t\treturn \$result;\n";
Expand Down
Loading