From 8279cc37b443f8bae6220a96e8a12a665e92f0f9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 15 Jan 2013 10:39:16 +0100 Subject: [PATCH] remove notnorm gen model --- core/lib/Thelia/Model/Accessory.php | 50 -- core/lib/Thelia/Model/Address.php | 9 - core/lib/Thelia/Model/Admin.php | 9 - core/lib/Thelia/Model/AdminGroup.php | 9 - core/lib/Thelia/Model/AdminLog.php | 9 - core/lib/Thelia/Model/Area.php | 9 - core/lib/Thelia/Model/Attribute.php | 9 - core/lib/Thelia/Model/AttributeAv.php | 9 - core/lib/Thelia/Model/AttributeAvDesc.php | 9 - core/lib/Thelia/Model/AttributeCategory.php | 9 - .../lib/Thelia/Model/AttributeCombination.php | 9 - core/lib/Thelia/Model/AttributeDesc.php | 9 - core/lib/Thelia/Model/Base/Base.php | 477 ------------------ core/lib/Thelia/Model/Category.php | 9 - core/lib/Thelia/Model/CategoryDesc.php | 9 - core/lib/Thelia/Model/Combination.php | 9 - core/lib/Thelia/Model/Config.php | 87 ---- core/lib/Thelia/Model/ConfigDesc.php | 9 - core/lib/Thelia/Model/Content.php | 9 - core/lib/Thelia/Model/ContentAssoc.php | 9 - core/lib/Thelia/Model/ContentDesc.php | 9 - core/lib/Thelia/Model/ContentFolder.php | 9 - core/lib/Thelia/Model/Country.php | 9 - core/lib/Thelia/Model/CountryDesc.php | 9 - core/lib/Thelia/Model/Coupon.php | 9 - core/lib/Thelia/Model/CouponOrder.php | 9 - core/lib/Thelia/Model/CouponRule.php | 9 - core/lib/Thelia/Model/Currency.php | 9 - core/lib/Thelia/Model/Customer.php | 9 - core/lib/Thelia/Model/CustomerTitle.php | 9 - core/lib/Thelia/Model/CustomerTitleDesc.php | 9 - core/lib/Thelia/Model/Delivzone.php | 9 - core/lib/Thelia/Model/Document.php | 9 - core/lib/Thelia/Model/DocumentDesc.php | 9 - core/lib/Thelia/Model/Feature.php | 9 - core/lib/Thelia/Model/FeatureAv.php | 9 - core/lib/Thelia/Model/FeatureAvDesc.php | 9 - core/lib/Thelia/Model/FeatureCategory.php | 9 - core/lib/Thelia/Model/FeatureDesc.php | 9 - core/lib/Thelia/Model/FeatureProd.php | 9 - core/lib/Thelia/Model/Folder.php | 9 - core/lib/Thelia/Model/FolderDesc.php | 9 - core/lib/Thelia/Model/Group.php | 9 - core/lib/Thelia/Model/GroupDesc.php | 9 - core/lib/Thelia/Model/GroupModule.php | 9 - core/lib/Thelia/Model/GroupResource.php | 9 - core/lib/Thelia/Model/Image.php | 9 - core/lib/Thelia/Model/ImageDesc.php | 9 - core/lib/Thelia/Model/Lang.php | 9 - core/lib/Thelia/Model/Message.php | 9 - core/lib/Thelia/Model/MessageDesc.php | 9 - core/lib/Thelia/Model/Module.php | 9 - core/lib/Thelia/Model/ModuleDesc.php | 9 - core/lib/Thelia/Model/Order.php | 9 - core/lib/Thelia/Model/OrderAddress.php | 9 - core/lib/Thelia/Model/OrderFeature.php | 9 - core/lib/Thelia/Model/OrderProduct.php | 9 - core/lib/Thelia/Model/OrderStatus.php | 9 - core/lib/Thelia/Model/OrderStatusDesc.php | 9 - core/lib/Thelia/Model/Product.php | 9 - core/lib/Thelia/Model/ProductCategory.php | 9 - core/lib/Thelia/Model/ProductDesc.php | 9 - core/lib/Thelia/Model/Resource.php | 9 - core/lib/Thelia/Model/ResourceDesc.php | 9 - core/lib/Thelia/Model/Rewriting.php | 9 - core/lib/Thelia/Model/Stock.php | 9 - core/lib/Thelia/Model/Tax.php | 9 - core/lib/Thelia/Model/TaxDesc.php | 9 - core/lib/Thelia/Model/TaxQuery.php | 9 - core/lib/Thelia/Model/TaxRule.php | 9 - core/lib/Thelia/Model/TaxRuleCountry.php | 9 - core/lib/Thelia/Model/TaxRuleDesc.php | 9 - 72 files changed, 1235 deletions(-) delete mode 100644 core/lib/Thelia/Model/Accessory.php delete mode 100644 core/lib/Thelia/Model/Address.php delete mode 100644 core/lib/Thelia/Model/Admin.php delete mode 100644 core/lib/Thelia/Model/AdminGroup.php delete mode 100644 core/lib/Thelia/Model/AdminLog.php delete mode 100644 core/lib/Thelia/Model/Area.php delete mode 100644 core/lib/Thelia/Model/Attribute.php delete mode 100644 core/lib/Thelia/Model/AttributeAv.php delete mode 100644 core/lib/Thelia/Model/AttributeAvDesc.php delete mode 100644 core/lib/Thelia/Model/AttributeCategory.php delete mode 100644 core/lib/Thelia/Model/AttributeCombination.php delete mode 100644 core/lib/Thelia/Model/AttributeDesc.php delete mode 100644 core/lib/Thelia/Model/Base/Base.php delete mode 100644 core/lib/Thelia/Model/Category.php delete mode 100644 core/lib/Thelia/Model/CategoryDesc.php delete mode 100644 core/lib/Thelia/Model/Combination.php delete mode 100644 core/lib/Thelia/Model/Config.php delete mode 100644 core/lib/Thelia/Model/ConfigDesc.php delete mode 100644 core/lib/Thelia/Model/Content.php delete mode 100644 core/lib/Thelia/Model/ContentAssoc.php delete mode 100644 core/lib/Thelia/Model/ContentDesc.php delete mode 100644 core/lib/Thelia/Model/ContentFolder.php delete mode 100644 core/lib/Thelia/Model/Country.php delete mode 100644 core/lib/Thelia/Model/CountryDesc.php delete mode 100644 core/lib/Thelia/Model/Coupon.php delete mode 100644 core/lib/Thelia/Model/CouponOrder.php delete mode 100644 core/lib/Thelia/Model/CouponRule.php delete mode 100644 core/lib/Thelia/Model/Currency.php delete mode 100644 core/lib/Thelia/Model/Customer.php delete mode 100644 core/lib/Thelia/Model/CustomerTitle.php delete mode 100644 core/lib/Thelia/Model/CustomerTitleDesc.php delete mode 100644 core/lib/Thelia/Model/Delivzone.php delete mode 100644 core/lib/Thelia/Model/Document.php delete mode 100644 core/lib/Thelia/Model/DocumentDesc.php delete mode 100644 core/lib/Thelia/Model/Feature.php delete mode 100644 core/lib/Thelia/Model/FeatureAv.php delete mode 100644 core/lib/Thelia/Model/FeatureAvDesc.php delete mode 100644 core/lib/Thelia/Model/FeatureCategory.php delete mode 100644 core/lib/Thelia/Model/FeatureDesc.php delete mode 100644 core/lib/Thelia/Model/FeatureProd.php delete mode 100644 core/lib/Thelia/Model/Folder.php delete mode 100644 core/lib/Thelia/Model/FolderDesc.php delete mode 100644 core/lib/Thelia/Model/Group.php delete mode 100644 core/lib/Thelia/Model/GroupDesc.php delete mode 100644 core/lib/Thelia/Model/GroupModule.php delete mode 100644 core/lib/Thelia/Model/GroupResource.php delete mode 100644 core/lib/Thelia/Model/Image.php delete mode 100644 core/lib/Thelia/Model/ImageDesc.php delete mode 100644 core/lib/Thelia/Model/Lang.php delete mode 100644 core/lib/Thelia/Model/Message.php delete mode 100644 core/lib/Thelia/Model/MessageDesc.php delete mode 100644 core/lib/Thelia/Model/Module.php delete mode 100644 core/lib/Thelia/Model/ModuleDesc.php delete mode 100644 core/lib/Thelia/Model/Order.php delete mode 100644 core/lib/Thelia/Model/OrderAddress.php delete mode 100644 core/lib/Thelia/Model/OrderFeature.php delete mode 100644 core/lib/Thelia/Model/OrderProduct.php delete mode 100644 core/lib/Thelia/Model/OrderStatus.php delete mode 100644 core/lib/Thelia/Model/OrderStatusDesc.php delete mode 100644 core/lib/Thelia/Model/Product.php delete mode 100644 core/lib/Thelia/Model/ProductCategory.php delete mode 100644 core/lib/Thelia/Model/ProductDesc.php delete mode 100644 core/lib/Thelia/Model/Resource.php delete mode 100644 core/lib/Thelia/Model/ResourceDesc.php delete mode 100644 core/lib/Thelia/Model/Rewriting.php delete mode 100644 core/lib/Thelia/Model/Stock.php delete mode 100644 core/lib/Thelia/Model/Tax.php delete mode 100644 core/lib/Thelia/Model/TaxDesc.php delete mode 100644 core/lib/Thelia/Model/TaxQuery.php delete mode 100644 core/lib/Thelia/Model/TaxRule.php delete mode 100644 core/lib/Thelia/Model/TaxRuleCountry.php delete mode 100644 core/lib/Thelia/Model/TaxRuleDesc.php diff --git a/core/lib/Thelia/Model/Accessory.php b/core/lib/Thelia/Model/Accessory.php deleted file mode 100644 index bf59b08a5..000000000 --- a/core/lib/Thelia/Model/Accessory.php +++ /dev/null @@ -1,50 +0,0 @@ -product_id; - } - - public function setProductId($product_id) - { - $this->product_id = $product_id; - } - - public function getAccessory() - { - return $this->accessory; - } - - public function setAccessory($accessory) - { - $this->accessory = $accessory; - } - - public function getPosition() - { - return $this->position; - } - - public function setPosition($position) - { - $this->position = $position; - } - -} diff --git a/core/lib/Thelia/Model/Address.php b/core/lib/Thelia/Model/Address.php deleted file mode 100644 index 6ac5cf37b..000000000 --- a/core/lib/Thelia/Model/Address.php +++ /dev/null @@ -1,9 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Model\Base; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * - * Abstract class. All model classes inherit from this class - * - * @author Manuel Raynaud - */ -abstract class Base -{ - /** - * Primary key - * @var int - */ - protected $id; - /** - * - * @var \NotORM - */ - protected $db; - - /** - * - * @var Symfony\Component\DependencyInjection\ContainerInterface - */ - protected $container; - - /** - * - * Short name of the current class instance - * - * @var string - */ - protected $className; - - /** - * - * @var string - */ - protected $table; - - /** - * - * @var string date when the record had been updated - */ - protected $updated_at; - - /** - * - * @var string date when the record had been saved - */ - protected $created_at; - /** - * - * base properties for all models - * - * @var array - */ - private $baseProperties = array( - "created_at", - "updated_at" - ); - - /** - * - * @param \NotORM $NotORM - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - */ - public function __construct(\NotORM $NotORM, ContainerInterface $container) - { - $this->db = $NotORM; - $this->className = $this->getShortClassName(); - $this->table = $this->underscore($this->className); - $this->container = $container; - } - - /** - * - * return the date and time when the record had been updated. - * - * @return \DateTime - */ - public function getUpdatedAt() - { - if ($this->updated_at) { - return new \DateTime($this->updated_at); - } else { - return null; - } - } - - /** - * - * return the raw date time when the record had been updated - * - * @return string - */ - public function getRawUpadtedAt() - { - return $this->updated_at; - } - - /** - * - * string date time when the record had been updated - * - * @param string $updated_at - */ - public function setUpdatedAt($updated_at) - { - $this->updated_at = $updated_at; - } - - /** - * - * return the date and time when the record had been created. - * - * @return \DateTime - */ - public function getCreatedAt() - { - if ($this->created_at) { - return new \DateTime($this->created_at); - } else { - return null; - } - } - - /** - * - * return the raw date time when the record had been created - * - * @return string - */ - public function getRawCreatedAt() - { - return $this->created_at; - } - - /** - * - * string date time when the record had been updated - * - * @param string $created_at - */ - public function setCreatedAt($created_at) - { - $this->created_at = $created_at; - } - - /** - * - * return the base properties like created_at, updated_at - * - * @return array - */ - private function getBaseProperties() - { - return $this->baseProperties; - } - - /** - * - * return the public properties of the current model. - * - * @return array - */ - public function getProperties() - { - return $this->properties; - } - - /** - * - * return the id of the current record - * - * @return type - */ - public function getId() - { - return $this->id; - } - - /** - * - * fix the id if needed - * - * @param int $id - */ - public function setId($id) - { - $this->id = $id; - } - - /** - * - * @return string Name of the current Table - */ - public function getTable() - { - return $this->table; - } - - /** - * - * @return \NotORM - */ - public function getConnection() - { - return $this->db; - } - - /** - * - * @return Symfony\Component\DependencyInjection\ContainerInterface - */ - public function getContainer() - { - return $this->container; - } - - /** - * - * return the short name (without namespace) of the current instance class name. - * - * @return string - */ - public function getClassName() - { - return $this->className; - } - - /** - * Persist data in current table - * - * Same method for saving or updating a record - * - */ - public function save() - { - if ($this->isNew()) { - $this->updated_at = $this->created_at = date('Y-m-d H:i:s'); - } else { - $this->updated_at = date("Y-m-d H:i:s"); - } - - $values = $this->prepare(); - $table = $this->getTable(); - $this->getConnection()->$table()->insert_update( - array("id", $this->getId()), - $values, - $values - ); - - } - - /** - * - * Find record by primary key - * - * @param int $pk - * @return Object - */ - public function find($pk) - { - $table = $this->getTable(); - - $result = $this->getConnection()->$table()->where("id", $pk); - - return $this->parseOneQuery($result); - } - - /** - * - * Find record for a specific column - * - * @param mixed $column column name - * @param mixed $search value searching - * @return array - * @throws \InvalidArgumentException column name cannot be empty - */ - public function findBy($column, $search) - { - - if (empty($column)) { - throw new \InvalidArgumentException("Column name cannot be emtpy"); - } - - $table = $this->getTable(); - - $result = $this->getConnection()->$table()->where($column, $search); - - return $this->parseQuery($result); - } - - /** - * - * Find the first record for a specific column - * - * @param mixed $column column name - * @param mixed $search value searching - * @return Object - * @throws \InvalidArgumentException column name cannot be empty - */ - public function findOneBy($column, $search) - { - - if (empty($column)) { - throw new \InvalidArgumentException("Column name cannot be emtpy"); - } - - $table = $this->getTable(); - - $result = $this->getConnection()->$table()->where($column, $search)->limit(1); - - return $this->parseOneQuery($result); - } - - /** - * - * delete the current record - * - * @return int - * @throws \RuntimeException - */ - public function delete() - { - if ($this->isNew()) { - throw new \RuntimeException("Cannot delete row. id is empty"); - } - - $table = $this->getTable(); - - return $this->getConnection()->$table() - ->where("id", $this->getId()) - ->delete(); - } - - /** - * - * @param \NotORM_Result $results - * @return array - */ - private function parseQuery(\NotORM_Result $results) - { - $return = array(); - $properties = array_merge($this->getBaseProperties(), $this->getProperties()); - - // @TODO : change hard code assignation - array_push($properties, "id"); - foreach ($results as $result) { - //$class = new static($this->getConnection()); - $class = $this->getContainer()->get("model.".$this->getClassName()); - - foreach ($properties as $property) { - call_user_func(array($class, "set".ucfirst(self::camelize($property))), $result[$property]); - } - array_push($return, $class); - } - - return $return; - } - - private function parseOneQuery(\NotORM_Result $results) - { - $return = $this->parseQuery($results); - - return count($return) ? $return[0] : null ; - } - - /** - * - * prepare an array for persisting data - * - * @return Array - */ - private function prepare() - { - $properties = array_merge($this->getBaseProperties(), $this->getProperties()); - - $values = array(); - - foreach ($properties as $property) { - $values[$property] = $this->$property; - } - - return $values; - } - - /** - * - * check if the current record is new or not. - * - * @return boolean - */ - public function isNew() - { - return $this->getId() ? false:true; - } - - /** - * - * @return string name of the current table - */ - protected function getShortClassName() - { - $info = new \ReflectionObject($this); - - return $info->getShortName(); - } - - /** - * - * extract from symfony 1.4 - * - * change camelized wirnd into underscore word. - * - * ex : AttributeCategory => attribute_category - * - * @param string $camel_cased_word - * @return string - */ - protected function underscore($camel_cased_word) - { - $tmp = $camel_cased_word; - $tmp = str_replace('::', '/', $tmp); - $tmp = self::pregtr($tmp, array('/([A-Z]+)([A-Z][a-z])/' => '\\1_\\2', - '/([a-z\d])([A-Z])/' => '\\1_\\2')); - - return strtolower($tmp); - } - - /** - * Returns a camelized string from a lower case and underscored string by replaceing slash with - * double-colon and upper-casing each letter preceded by an underscore. - * - * @param string $lower_case_and_underscored_word String to camelize. - * - * @return string Camelized string. - */ - public static function camelize($lower_case_and_underscored_word) - { - $tmp = $lower_case_and_underscored_word; - $tmp = self::pregtr($tmp, array('#/(.?)#e' => "'::'.strtoupper('\\1')",'/(^|_|-)+(.)/e' => "strtoupper('\\2')")); - - return $tmp; - } - - public static function pregtr($search, $replacePairs) - { - return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search); - } -} diff --git a/core/lib/Thelia/Model/Category.php b/core/lib/Thelia/Model/Category.php deleted file mode 100644 index 7b3052924..000000000 --- a/core/lib/Thelia/Model/Category.php +++ /dev/null @@ -1,9 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ -namespace Thelia\Model; - -use Thelia\Model\Base\Base; - -class Config extends Base -{ - protected $name; - protected $value; - protected $secure; - protected $hidden; - - protected $properties = array( - "name", - "value", - "secure", - "hidden" - ); - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getValue() - { - return $this->value; - } - - public function setValue($value) - { - $this->value = $value; - } - - public function getSecure() - { - return $this->secure; - } - - public function setSecure($secure) - { - $this->secure = $secure; - } - - public function getHidden() - { - return $this->hidden; - } - - public function setHidden($hidden) - { - $this->hidden = $hidden; - } - - public function read($search, $default) - { - $result = $this->findOneBy("name",$search); - - return $result ? $result->getValue() : $default; - } -} diff --git a/core/lib/Thelia/Model/ConfigDesc.php b/core/lib/Thelia/Model/ConfigDesc.php deleted file mode 100644 index 1bc53a128..000000000 --- a/core/lib/Thelia/Model/ConfigDesc.php +++ /dev/null @@ -1,9 +0,0 @@ -