partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit e6b77f77ffc760f826f5bd4ca9d2b306da0dde47
parent ede383802049e0576edc24200b701f46fb368b15
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu, 16 Jun 2011 11:46:05 +0800

Refactored many entities to the new BaseEntity model. Added much documentation and removed quite some legacy code. However, I'm still not satisfied, especially with the Managers.

Diffstat:
Mfrontend/js/Components/Footprint/FootprintEditor.js | 2+-
Mfrontend/js/Components/Footprint/FootprintGrid.js | 2+-
Mfrontend/js/Models/Footprint.js | 4++--
Msrc/de/RaumZeitLabor/PartKeepr/Category/Category.php | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Msrc/de/RaumZeitLabor/PartKeepr/Category/CategoryManager.php | 61+++++++++++++++++++++++++++++++++++++++++++++++++------------
Msrc/de/RaumZeitLabor/PartKeepr/Category/CategoryService.php | 38+++++++++++++++++++++++++-------------
Msrc/de/RaumZeitLabor/PartKeepr/Category/Exceptions/CategoryNotFoundException.php | 7+++++--
Msrc/de/RaumZeitLabor/PartKeepr/Distributor/Distributor.php | 124++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Msrc/de/RaumZeitLabor/PartKeepr/Distributor/DistributorManager.php | 35++++++++++++++++++++++++++++-------
Msrc/de/RaumZeitLabor/PartKeepr/Distributor/DistributorService.php | 87+++++++++++++++++++------------------------------------------------------------
Dsrc/de/RaumZeitLabor/PartKeepr/Footprint/Exceptions/FootprintNotFoundException.php | 13-------------
Msrc/de/RaumZeitLabor/PartKeepr/Footprint/Footprint.php | 49++++++++++++++++++++++++++++++-------------------
Msrc/de/RaumZeitLabor/PartKeepr/Footprint/FootprintManager.php | 92+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Msrc/de/RaumZeitLabor/PartKeepr/Footprint/FootprintService.php | 62++++++++++++++++++--------------------------------------------
Msrc/de/RaumZeitLabor/PartKeepr/Image/Exceptions/InvalidImageTypeException.php | 3+++
Dsrc/de/RaumZeitLabor/PartKeepr/Image/TempImage.php | 21---------------------
Msrc/de/RaumZeitLabor/PartKeepr/Manufacturer/Manufacturer.php | 115++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
Msrc/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerICLogo.php | 37++++++++++++++++++++++++++++++++-----
Msrc/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerManager.php | 37++++++++++++++++++++++++++-----------
Msrc/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerService.php | 87+++++++++++++++++++------------------------------------------------------------
Msrc/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoManager.php | 38+++++++++++++++-----------------------
Msrc/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoService.php | 20++++++++++++++++++--
Msrc/de/RaumZeitLabor/PartKeepr/Part/Part.php | 135+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
Msrc/de/RaumZeitLabor/PartKeepr/Part/PartDistributor.php | 70++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
Msrc/de/RaumZeitLabor/PartKeepr/Part/PartManager.php | 12++++++++----
Msrc/de/RaumZeitLabor/PartKeepr/Part/PartManufacturer.php | 17+++++------------
Msrc/de/RaumZeitLabor/PartKeepr/PartDistributor/PartDistributorService.php | 3+--
Msrc/de/RaumZeitLabor/PartKeepr/PartKeepr.php | 2+-
Msrc/de/RaumZeitLabor/PartKeepr/SiPrefix/SiPrefix.php | 28+++-------------------------
Asrc/de/RaumZeitLabor/PartKeepr/TempImage/TempImage.php | 21+++++++++++++++++++++
Msrc/de/RaumZeitLabor/PartKeepr/Unit/Unit.php | 28+++-------------------------
Msrc/de/RaumZeitLabor/PartKeepr/UploadedFile/UploadedFile.php | 32+++-----------------------------
Asrc/de/RaumZeitLabor/PartKeepr/Util/Serializable.php | 12++++++++++++
Mtesting/SetupDatabase.php | 2+-
34 files changed, 868 insertions(+), 563 deletions(-)

diff --git a/frontend/js/Components/Footprint/FootprintEditor.js b/frontend/js/Components/Footprint/FootprintEditor.js @@ -3,7 +3,7 @@ Ext.define('PartKeepr.FootprintEditor', { alias: 'widget.FootprintEditor', items: [{ xtype: 'textfield', - name: 'footprint', + name: 'name', fieldLabel: i18n("Footprint") }], saveText: i18n("Save Footprint"), diff --git a/frontend/js/Components/Footprint/FootprintGrid.js b/frontend/js/Components/Footprint/FootprintGrid.js @@ -2,7 +2,7 @@ Ext.define('PartKeepr.FootprintGrid', { extend: 'PartKeepr.EditorGrid', alias: 'widget.FootprintGrid', columns: [ - {header: i18n("Footprint"), dataIndex: 'footprint', flex: 1} + {header: i18n("Footprint"), dataIndex: 'name', flex: 1} ], addButtonText: i18n("Add Footprint"), deleteButtonText: i18n("Delete Footprint") diff --git a/frontend/js/Models/Footprint.js b/frontend/js/Models/Footprint.js @@ -2,10 +2,10 @@ PartKeepr.Footprint = Ext.define("Footprint", { extend: "Ext.data.Model", fields: [ { id: 'id', name: 'id', type: 'int' }, - { name: 'footprint', type: 'string'} + { name: 'name', type: 'string'} ], proxy: PartKeepr.getRESTProxy("Footprint"), getName: function () { - return this.get("footprint"); + return this.get("name"); } }); \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Category/Category.php b/src/de/RaumZeitLabor/PartKeepr/Category/Category.php @@ -1,71 +1,153 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Category; -declare(encoding = 'UTF-8'); +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; use DoctrineExtensions\NestedSet\Node; -/** @Entity @Table(indexes={@index(name="lft", columns={"lft"}),@index(name="rgt", columns={"rgt"})}) */ -class Category implements Node { - /** @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - */ - private $id; - - /** +declare(encoding = 'UTF-8'); + +/** + * @Entity + * @Table(indexes={@index(name="lft", columns={"lft"}),@index(name="rgt", columns={"rgt"})}) + * + * Represents a category within the system. + */ +class Category extends BaseEntity implements Node, Serializable { + /** + * The "left" property of the nested set * @Column(type="integer") + * @var integer */ private $lft; /** + * The "right" property of the nested set * @Column(type="integer") + * @var integer */ private $rgt; - /** @Column(length=128) */ + /** + * The name of the category + * @Column(length=128) + * @var string + */ private $name; - /** @Column(length=32768) */ + /** + * The description of the category + * @Column(type="text") + * @var string + */ private $description; + /** + * Holds the parent node ID. Note that this + * is not a persistant value, but rather calculated + * or set on the fly. + * @var int + */ private $parent; + /** + * Sets the name of this category + * @param string $name The name to set + */ public function setName ($name) { $this->name = $name; } + /** + * Returns the name of this category + * @return string The category name + */ + public function getName () { + return $this->name; + } + + /** + * Sets the parent for this category. + * + * @param int $id The parent node + */ public function setParent ($id) { $this->parent = $id; } + /** + * Returns the parent node for this node. + * @return int The parent node + */ public function getParent () { return $this->parent; } + /** + * Sets the description for this category + * @param string $description The description of this category + */ public function setDescription ($description) { $this->description = $description; } - - public function getName () { - return $this->name; + /** + * Returns the description of this category + * @return string The description + */ + public function getDescription () { + return $this->description; } - public function getId() { return $this->id; } - - public function getLeftValue() { return $this->lft; } - public function setLeftValue($lft) { $this->lft = $lft; } + + /** + * (non-PHPdoc) + * @see DoctrineExtensions\NestedSet.Node::getLeftValue() + */ + public function getLeftValue() { + return $this->lft; + } + + /** + * (non-PHPdoc) + * @see DoctrineExtensions\NestedSet.Node::setLeftValue() + */ + public function setLeftValue($lft) { + $this->lft = $lft; + } - public function getRightValue() { return $this->rgt; } - public function setRightValue($rgt) { $this->rgt = $rgt; } + /** + * (non-PHPdoc) + * @see DoctrineExtensions\NestedSet.Node::getRightValue() + */ + public function getRightValue() { + return $this->rgt; + } + + /** + * (non-PHPdoc) + * @see DoctrineExtensions\NestedSet.Node::setRightValue() + */ + public function setRightValue($rgt) { + $this->rgt = $rgt; + } + /** + * Serializes the entity. + */ public function serialize () { return array( - "id" => $this->id, - "name" => $this->name, - "description" => $this->description - + "id" => $this->getId(), + "name" => $this->getName(), + "description" => $this->getDescription() ); } - public function __toString () {} + /** + * (non-PHPdoc) + * @see DoctrineExtensions\NestedSet.Node::__toString() + */ + public function __toString () { + return $this->getName(); + } + } -?>- \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Category/CategoryManager.php b/src/de/RaumZeitLabor/PartKeepr/Category/CategoryManager.php @@ -12,8 +12,17 @@ use DoctrineExtensions\NestedSet\Config; use DoctrineExtensions\NestedSet\NodeWrapper; class CategoryManager extends Singleton { + /** + * Holds the node manager + * @var object The node manager + */ private $nodeManager; - + + /** + * Returns the node manager. Creates it if it doesn't exist. + * @todo Can this method be made private? + * @return Manager The node manager + */ public function getNodeManager () { if (!$this->nodeManager) { $config = new Config(PartKeepr::getEM(), 'de\RaumZeitLabor\PartKeepr\Category\Category'); @@ -23,7 +32,13 @@ class CategoryManager extends Singleton { return $this->nodeManager; } - + + /** + * Returns the child node id's for a given node id. + * @param integer $id The ID for which to retrieve the child nodes + * @return array An array of the children id's + * @todo Refactor this method name to indicate that it operates on IDs only. + */ public function getChildNodes ($id) { $category = $this->getCategory($id); @@ -35,11 +50,17 @@ class CategoryManager extends Singleton { return $aData; } + /** + * Returns all categories. + * @return The category tree + */ public function getAllCategories () { return $this->getNodeManager()->fetchTree(1); } - + /** + * Ensures that the root node exists. If not, this method creates it. + */ public function ensureRootExists () { /* Check if the root node exists */ $rootNode = $this->getNodeManager()->fetchTree(1); @@ -49,10 +70,17 @@ class CategoryManager extends Singleton { } } + /** + * Returns the root node for the category tree. + * @return The category root node + */ public function getRootNode () { return $this->getNodeManager()->fetchTree(1); } + /** + * Create the root node for the category tree. + */ public function createRootNode () { $rootNode = new Category(); $rootNode->setName("Root Category"); @@ -61,6 +89,11 @@ class CategoryManager extends Singleton { $this->getNodeManager()->createRoot($rootNode); } + /** + * Adds a given category. + * @param Category $category The category to add to the tree + * @return Category the added category + */ public function addCategory (Category $category) { $parent = $category->getParent(); @@ -74,10 +107,13 @@ class CategoryManager extends Singleton { } return $parent->addChild($category); - - } - + + /** + * Deletes the given category ID. + * @param $id int The category id to delete + * @throws CategoryNotFoundException If the category wasn't found + */ public function deleteCategory ($id) { $category = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Category\Category", $id); @@ -103,14 +139,15 @@ class CategoryManager extends Singleton { } } else { - throw new CategoryNotFoundException; + throw new CategoryNotFoundException($id); } } - public function saveCategory ($category) { - PartKeepr::getEM()->persist($category); - } - + /** + * Returns the category with the given ID. + * @param int $id The category id + * @throws CategoryNotFoundException If the category wasn't found + */ public function getCategory ($id) { $category = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Category\Category", $id); @@ -121,7 +158,7 @@ class CategoryManager extends Singleton { return $category; } else { - throw new CategoryNotFoundException; + throw new CategoryNotFoundException($id); } } diff --git a/src/de/RaumZeitLabor/PartKeepr/Category/CategoryService.php b/src/de/RaumZeitLabor/PartKeepr/Category/CategoryService.php @@ -1,5 +1,7 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Category; +use de\RaumZeitLabor\PartKeepr\PartKeepr; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\Service\Service; @@ -9,6 +11,10 @@ use DoctrineExtensions\NestedSet\NodeWrapper; class CategoryService extends Service { + /** + * Returns all categories found in the system. + * @return array A serialized tree + */ public function getCategories () { $categories = CategoryManager::getInstance()->getAllCategories( $this->getParameter("parent", 0)); @@ -16,6 +22,9 @@ class CategoryService extends Service { return $this->serializeTree($categories); } + /** + * Moves the given category from one to another category. + */ public function moveCategory () { $this->requireParameter("category"); $this->requireParameter("target"); @@ -30,7 +39,10 @@ class CategoryService extends Service { } } - + + /** + * Deletes the given category. + */ public function deleteCategory () { $this->requireParameter("id"); @@ -39,6 +51,9 @@ class CategoryService extends Service { return array("id" => $this->getParameter("id")); } + /** + * Updates the given category. + */ public function update () { $this->requireParameter("id"); $this->requireParameter("name"); @@ -48,7 +63,7 @@ class CategoryService extends Service { $category->getNode()->setName($this->getParameter("name")); $category->getNode()->setDescription($this->getParameter("description", "")); - CategoryManager::getInstance()->saveCategory($category->getNode()); + PartKeepr::getEM()->persist($category->getNode()); return array("data" => $this->serializeCategory($category)); } @@ -66,17 +81,6 @@ class CategoryService extends Service { return array("data" => $this->serializeCategory($category)); } - - // Old stuff below - - public function getCategory () { - $this->requireParameter("id"); - - $category = CategoryManager::getInstance()->getCategory($this->getParameter("id")); - - return $this->serializeCategory($category); - - } private function serializeCategory ($category) { $data = $category->getNode()->serialize(); @@ -89,10 +93,18 @@ class CategoryService extends Service { return $data; } + /** + * Returns all categories + */ public function getAllCategories () { return $this->serializeTree(CategoryManager::getInstance()->getAllCategories()); } + /** + * Serializes the given NodeWrapper as array including all children. + * @param NodeWrapper $node The category nodewrapper to serialize + * @throws \Exception + */ public function serializeTree (NodeWrapper $node = null) { if ($node == null) { throw new \Exception("Node must not be null!"); diff --git a/src/de/RaumZeitLabor/PartKeepr/Category/Exceptions/CategoryNotFoundException.php b/src/de/RaumZeitLabor/PartKeepr/Category/Exceptions/CategoryNotFoundException.php @@ -4,9 +4,12 @@ namespace de\RaumZeitLabor\PartKeepr\Category\Exceptions; use de\RaumZeitLabor\PartKeepr\Util\SerializableException, de\RaumZeitLabor\PartKeepr\PartKeepr; +/** + * Thrown when the requested category was not found. + */ class CategoryNotFoundException extends SerializableException { - public function __construct () { - parent::__construct(PartKeepr::i18n("Category not found.")); + public function __construct ($id) { + parent::__construct(sprintf(PartKeepr::i18n("Category %d not found."), $id)); } } ?> \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Distributor/Distributor.php b/src/de/RaumZeitLabor/PartKeepr/Distributor/Distributor.php @@ -1,121 +1,191 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Distributor; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr; -/** @Entity **/ -class Distributor { - - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var unknown_type - */ - private $id; - +/** + * Represents a distributor + * @Entity **/ +class Distributor extends BaseEntity implements Serializable { /** + * Holds the name of the distributor * @Column(type="string",unique=true) + * @var string */ private $name; /** - * @Column(type="string",nullable=true) + * Holds the address of the distributor + * @Column(type="text",nullable=true) + * @var string */ private $address; /** + * Holds the URL of the distributor * @Column(type="string",nullable=true) + * @var string */ private $url; /** + * Holds the phone number of the distributor * @Column(type="string",nullable=true) + * @var string */ private $phone; /** + * Holds the fax number of the distributor * @Column(type="string",nullable=true) + * @var string */ private $fax; /** + * Holds the email of the distributor * @Column(type="string",nullable=true) + * @var string */ private $email; /** - * @Column(type="string",nullable=true) + * Holds a comment for the distributor + * @Column(type="text",nullable=true) + * @var string */ private $comment; - public function __construct () { - } + /** + * Sets the name for the distributor + * + * @param string $name The distributor's name + */ public function setName ($name) { $this->name = $name; } + /** + * Returns the name of the distributor + * @return string The distributor's name + */ public function getName () { return $this->name; } + /** + * Sets the address of this distributor + * + * @param string $address The address of the distributor + */ public function setAddress ($address) { $this->address = $address; } + /** + * Returns the address of this distributor + * @return string The address of this distributor + */ public function getAddress () { return $this->address; } + /** + * Sets the phone number for this distributor + * + * @param string $phone The phone number of this distributor + */ public function setPhone ($phone) { $this->phone = $phone; } + /** + * Returns the phone number of this distributor + * @return string The phone number + */ public function getPhone () { return $this->phone; } + /** + * Sets the fax number for this distributor + * + * @param string $fax The fax number + */ public function setFax ($fax) { $this->fax = $fax; } - public function getFax ($fax) { + /** + * Returns the fax number for this distributor + * + * @return string $fax The fax number + */ + public function getFax () { return $this->fax; } - + /** + * Sets the comment for this distributor + * + * @param string $comment The comment for this distributor + */ public function setComment ($comment) { $this->comment = $comment; } + /** + * Returns the comment for this distributor + * + * @return string The comment + */ public function getComment () { return $this->comment; } + /** + * Sets the email for this distributor + * + * @param string $email The email for this distributor + */ public function setEmail ($email) { $this->email = $email; } + /** + * Returns the email for this distributor + * @return string The email + */ public function getEmail () { return $this->email; } + /** + * Sets the URL for this distributor + * + * @param string $url The URL for this distributor + */ public function setURL ($url) { $this->url = $url; } + /** + * Returns the URL for this distributor + * @return string The URL + */ public function getURL () { return $this->url; } - - public function getICLogos () { - return $this->icLogos; - } - - public function getId () { - return $this->id; - } - + + /** + * Returns the distributor in serialized form. + * @return array The serialized distributor + */ public function serialize () { return array( "id" => $this->getId(), @@ -126,8 +196,4 @@ class Distributor { "comment" => $this->getComment() ); } - - public static function loadById ($id) { - return PartKeepr::getEM()->find(get_called_class(), $id); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Distributor/DistributorManager.php b/src/de/RaumZeitLabor/PartKeepr/Distributor/DistributorManager.php @@ -9,6 +9,15 @@ use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Distributor\Exceptions\DistributorNotFoundException; class DistributorManager extends Singleton { + /** + * Returns a list of distributors. + * + * @param int $start Start of the list, default 0 + * @param int $limit Number of users to list, default 10 + * @param string $sort The field to sort by, default "name" + * @param string $dir The direction to sort (ASC or DESC), default ASC + * @param string $filter A string to filter the distributor's name by, default empty + */ public function getDistributors ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { $qb = PartKeepr::getEM()->createQueryBuilder(); @@ -45,16 +54,22 @@ class DistributorManager extends Singleton { return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); } + /** + * Returns a distributor by ID. + * + * @param int $id The distributor id + * @return Distributor The distributor + * @throws EntityNotFoundException If no distributor with the ID was found + */ public function getDistributor ($id) { - $distributor = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Distributor\Distributor", $id); - - if ($distributor) { - return $distributor; - } else { - throw new DistributorNotFoundException(); - } + return Distributor::loadById($id); } + /** + * Creates a new distributor with the given name. + * @param string $name The name of the distributor + * @return Distributor The new distributor object + */ public function addDistributor ($name) { $distributor = new Distributor(); $distributor->setName($name); @@ -64,6 +79,12 @@ class DistributorManager extends Singleton { return $distributor; } + + /** + * Deletes a distributor by id + * + * @param int $id The ID of the distributor to delete + */ public function deleteDistributor ($id) { $distributor = $this->getDistributor($id); diff --git a/src/de/RaumZeitLabor/PartKeepr/Distributor/DistributorService.php b/src/de/RaumZeitLabor/PartKeepr/Distributor/DistributorService.php @@ -11,7 +11,11 @@ use de\RaumZeitLabor\PartKeepr\Part\PartManager, de\RaumZeitLabor\PartKeepr\Session\SessionManager; class DistributorService extends Service implements RestfulService { - public function get () { + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::get() + */ + public function get () { if ($this->hasParameter("id")) { return DistributorManager::getInstance()->getDistributor($this->getParameter("id"))->serialize(); } else { @@ -33,6 +37,10 @@ class DistributorService extends Service implements RestfulService { } } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() + */ public function create () { $this->requireParameter("name"); @@ -46,6 +54,10 @@ class DistributorService extends Service implements RestfulService { return array("data" => $distributor->serialize()); } + /** + * Sets the data for the distributor. + * @param Distributor $distributor The distributor to process + */ private function setDistributorData (Distributor $distributor) { $distributor->setName($this->getParameter("name")); $distributor->setComment($this->getParameter("comment", "")); @@ -54,6 +66,10 @@ class DistributorService extends Service implements RestfulService { $distributor->setEmail($this->getParameter("email", "")); } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::update() + */ public function update () { $this->requireParameter("id"); $this->requireParameter("name"); @@ -66,6 +82,10 @@ class DistributorService extends Service implements RestfulService { } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::destroy() + */ public function destroy () { $this->requireParameter("id"); @@ -73,69 +93,4 @@ class DistributorService extends Service implements RestfulService { return array("data" => null); } - - - // Old stuff below - public function getDistributors() { - return DistributorManager::getInstance()->getDistributors( - $this->getParameter("start", 0), - $this->getParameter("limit", 10), - $this->getParameter("sortby", "name"), - $this->getParameter("dir", "asc"), - $this->getParameter("filter", "")); - } - - public function addDistributor () { - $this->requireParameter("name"); - - DistributorManager::getInstance()->addDistributor($this->getParameter("name")); - } - - public function deleteDistributor () { - $this->requireParameter("id"); - - DistributorManager::getInstance()->deleteDistributor($this->getParameter("id")); - } - - public function deleteDistributorLogo () { - $this->requireParameter("id"); - - $logo = DistributorICLogo::loadById($this->getParameter("id")); - - PartKeepr::getEM()->remove($logo); - PartKeepr::getEM()->flush(); - } - - public function getDistributorLogos () { - $this->requireParameter("id"); - $distributor = DistributorManager::getInstance()->getDistributor($this->getParameter("id")); - - $aData = array(); - - foreach ($distributor->getICLogos() as $logo) { - $aData[] = array("id" => $logo->getId()); - } - - return array("logos" => $aData); - - } - - public function getDistributor () { - $this->requireParameter("id"); - - return DistributorManager::getInstance()->getDistributor($this->getParameter("id"))->serialize(); - } - - public function saveDistributor () { - $this->requireParameter("id"); - $this->requireParameter("name"); - - $Distributor = DistributorManager::getInstance()->getDistributor($this->getParameter("id")); - - $Distributor->setName($this->getParameter("name")); - - PartKeepr::getEM()->flush(); - - return $Distributor->serialize(); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Footprint/Exceptions/FootprintNotFoundException.php b/src/de/RaumZeitLabor/PartKeepr/Footprint/Exceptions/FootprintNotFoundException.php @@ -1,12 +0,0 @@ -<?php -namespace de\RaumZeitLabor\PartKeepr\Footprint\Exceptions; - -use de\RaumZeitLabor\PartKeepr\Util\SerializableException, - de\RaumZeitLabor\PartKeepr\PartKeepr; - -class FootprintNotFoundException extends SerializableException { - public function __construct () { - parent::__construct(PartKeepr::i18n("Footprint not found.")); - } -} -?>- \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Footprint/Footprint.php b/src/de/RaumZeitLabor/PartKeepr/Footprint/Footprint.php @@ -1,32 +1,43 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Footprint; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); /** @Entity */ -class Footprint { - /** @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") +class Footprint extends BaseEntity implements Serializable { + /** + * Holds the footprint name + * @Column(length=64,unique=true) + * @var string */ - private $id; - - /** @Column(length=64,unique=true) */ - private $footprint; - - public function setFootprint ($footprint) { - $this->footprint = $footprint; - } + private $name; - public function getId () { - return $this->id; + /** + * Sets the name of this footprint + * + * @param string $name The footprint name + */ + public function setName ($name) { + $this->name = $name; } - public function getFootprint () { - return $this->footprint; + /** + * Returns the name of this footprint + * @return string The name of this footprint + */ + public function getName () { + return $this->name; } + /** + * Serializes the footprint + * @return array the serialized footprint + */ public function serialize () { - return array("id" => $this->id, "footprint" => $this->footprint); + return array("id" => $this->getId(), "name" => $this->getName()); } -} -?>- \ No newline at end of file +}+ \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Footprint/FootprintManager.php b/src/de/RaumZeitLabor/PartKeepr/Footprint/FootprintManager.php @@ -1,21 +1,31 @@ <?php namespace de\raumzeitlabor\PartKeepr\Footprint; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Util\SerializableException, de\RaumZeitLabor\PartKeepr\Footprint\Footprint, de\RaumZeitLabor\PartKeepr\PartKeepr, - de\RaumZeitLabor\PartKeepr\Footprint\Exceptions\FootprintNotFoundException; + de\RaumZeitLabor\PartKeepr\Util\Exceptions\EntityNotFoundException; class FootprintManager extends Singleton { - public function getFootprints ($start = 0, $limit = 10, $sort = "footprint", $dir = "asc", $filter = "") { + /** + * Returns a list of footprints. + * + * @param int $start Start of the list, default 0 + * @param int $limit Number of users to list, default 10 + * @param string $sort The field to sort by, default "name" + * @param string $dir The direction to sort (ASC or DESC), default ASC + * @param string $filter A string to filter the footprint's name by, default empty + */ + public function getFootprints ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { $qb = PartKeepr::getEM()->createQueryBuilder(); - $qb->select("f.id, f.footprint")->from("de\RaumZeitLabor\PartKeepr\Footprint\Footprint","f"); + $qb->select("f.id, f.name")->from("de\RaumZeitLabor\PartKeepr\Footprint\Footprint","f"); if ($filter != "") { - $qb = $qb->where("f.footprint LIKE :filter"); + $qb = $qb->where("f.name LIKE :filter"); $qb->setParameter("filter", "%".$filter."%"); } @@ -36,7 +46,7 @@ class FootprintManager extends Singleton { if ($filter != "") { - $totalQueryBuilder = $totalQueryBuilder->where("f.footprint LIKE :filter"); + $totalQueryBuilder = $totalQueryBuilder->where("f.name LIKE :filter"); $totalQueryBuilder->setParameter("filter", "%".$filter."%"); } @@ -45,9 +55,16 @@ class FootprintManager extends Singleton { return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); } - public function addFootprint ($footprint) { + /** + * Creates a new footprint + * + * @param string $footprint The footprint's name + * @throws \de\RaumZeitLabor\PartKeepr\Util\SerializableException + * @throws PDOException + */ + public function addFootprint ($name) { $fp = new Footprint(); - $fp->setFootprint($footprint); + $fp->setName($name); // @todo Port the UniqueEntityValidator from Symfony2 to here. try { @@ -67,49 +84,54 @@ class FootprintManager extends Singleton { return $fp; } + /** + * Deletes the footprint with the given id. + * + * @param int $id The footprint id to delete + * @throws \de\RaumZeitLabor\PartKeepr\Util\SerializableException + */ public function deleteFootprint ($id) { - $footprint = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Footprint\Footprint", $id); + $footprint = Footprint::loadById($id); - if ($footprint) { - try { - PartKeepr::getEM()->remove($footprint); - PartKeepr::getEM()->flush(); - } catch (\PDOException $e) { - if ($e->getCode() == "23000") { - $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getFootprint())); - $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getFootprint())); - - throw $exception; - } - } + try { + PartKeepr::getEM()->remove($footprint); + PartKeepr::getEM()->flush(); + } catch (\PDOException $e) { + if ($e->getCode() == "23000") { + $exception = new SerializableException(sprintf(PartKeepr::i18n("Footprint %s is in use by some parts!"), $footprint->getName())); + $exception->setDetail(sprintf(PartKeepr::i18n("You tried to delete the footprint %s, but there are parts which use this footprint."), $footprint->getName())); - } else { - throw new FootprintNotFoundException; + throw $exception; + } } } + /** + * Finds or creates a footprint by name. + * + * @param mixed $footprint Either the ID or the footprint's name to find + */ public function getOrCreateFootprint ($footprint) { if (is_int($footprint)) { try { - return $this->getFootprint($footprint); - } catch (FootprintNotFoundException $e) {} + Footprint::loadById($footprint); + } catch (EntityNotFoundException $e) {} + } else { + $dql = "SELECT f FROM de\RaumZeitLabor\PartKeepr\Footprint\Footprint f WHERE f.name = :name"; + $query = PartKeepr::getEM()->createQuery($dql); + $query->setParameter("name", $footprint); + + try { + $footprint = $query->getSingleResult(); + return $footprint; + } catch (\Exception $e) {} } $fp = new Footprint(); - $fp->setFootprint($footprint); + $fp->setName($footprint); PartKeepr::getEM()->persist($fp); return $fp; } - - public function getFootprint ($id) { - $footprint = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Footprint\Footprint", $id); - - if ($footprint) { - return $footprint; - } else { - throw new FootprintNotFoundException; - } - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Footprint/FootprintService.php b/src/de/RaumZeitLabor/PartKeepr/Footprint/FootprintService.php @@ -8,6 +8,10 @@ use de\RaumZeitLabor\PartKeepr\Service\Service, de\RaumZeitLabor\PartKeepr\Footprint\FootprintManager; class FootprintService extends Service implements RestfulService { + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::get() + */ public function get () { if ($this->hasParameter("id")) { return FootprintManager::getInstance()->getFootprint($this->getParameter("id"))->serialize(); @@ -18,7 +22,7 @@ class FootprintService extends Service implements RestfulService { $aSortParams = $tmp[0]; } else { $aSortParams = array( - "property" => "footprint", + "property" => "name", "direction" => "ASC"); } return FootprintManager::getInstance()->getFootprints( @@ -30,6 +34,10 @@ class FootprintService extends Service implements RestfulService { } } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() + */ public function create () { $this->requireParameter("footprint"); @@ -38,11 +46,15 @@ class FootprintService extends Service implements RestfulService { return array("data" => $fp->serialize()); } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::update() + */ public function update () { $this->requireParameter("id"); $this->requireParameter("footprint"); $footprint = FootprintManager::getInstance()->getFootprint($this->getParameter("id")); - $footprint->setFootprint($this->getParameter("footprint")); + $footprint->setName($this->getParameter("footprint")); PartKeepr::getEM()->flush(); @@ -50,6 +62,10 @@ class FootprintService extends Service implements RestfulService { } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::destroy() + */ public function destroy () { $this->requireParameter("id"); @@ -58,45 +74,4 @@ class FootprintService extends Service implements RestfulService { return array("data" => null); } - /* Old stuff below */ - public function getFootprints () { - return FootprintManager::getInstance()->getFootprints( - $this->getParameter("start", 0), - $this->getParameter("limit", 10), - $this->getParameter("sortby", "footprint"), - $this->getParameter("dir", "asc"), - $this->getParameter("filter", "")); - } - - public function addFootprint () { - $this->requireParameter("footprint"); - - - } - - public function deleteFootprint () { - $this->requireParameter("id"); - - FootprintManager::getInstance()->deleteFootprint($this->getParameter("id")); - } - - public function getFootprint () { - $this->requireParameter("id"); - - return $this->get($this->getParameter("id")); - } - - public function saveFootprint () { - $this->requireParameter("id"); - $this->requireParameter("footprint"); - - $footprint = FootprintManager::getInstance()->getFootprint($this->getParameter("id")); - - $footprint->setFootprint($this->getParameter("footprint")); - - PartKeepr::getEM()->flush(); - - return $footprint->serialize(); - } } -?>- \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Image/Exceptions/InvalidImageTypeException.php b/src/de/RaumZeitLabor/PartKeepr/Image/Exceptions/InvalidImageTypeException.php @@ -1,6 +1,9 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Image\Exceptions; +/** + * Thrown if an invalid type was passed + */ class InvalidImageTypeException extends \Exception { public function __construct ($type) { parent::__construct("The image type $type is unknown."); diff --git a/src/de/RaumZeitLabor/PartKeepr/Image/TempImage.php b/src/de/RaumZeitLabor/PartKeepr/Image/TempImage.php @@ -1,20 +0,0 @@ -<?php -namespace de\RaumZeitLabor\PartKeepr\Image; -declare(encoding = 'UTF-8'); - -use de\RaumZeitLabor\PartKeepr\Image\Exceptions\InvalidImageTypeException, - de\RaumZeitLabor\PartKeepr\Util\Configuration, - de\RaumZeitLabor\PartKeepr\Image\Image, - de\RaumZeitLabor\PartKeepr\PartKeepr; - -/** - * Represents a temporary image. Temporary images are used when - * a user uploaded an image, but not attached it to an entity. - * - * @Entity - */ -class TempImage extends Image { - public function __construct () { - parent::__construct(Image::IMAGE_TEMP); - } -}- \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Manufacturer/Manufacturer.php b/src/de/RaumZeitLabor/PartKeepr/Manufacturer/Manufacturer.php @@ -1,126 +1,203 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Manufacturer; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr; -/** @Entity **/ -class Manufacturer { - - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var unknown_type - */ - private $id; - +/** + * Represents a manufacturer + * @Entity **/ +class Manufacturer extends BaseEntity implements Serializable { /** + * The name of the manufacturer * @Column(type="string",unique=true) + * @var string */ private $name; /** - * @Column(type="string",nullable=true) + * The address of the manufacturer + * @Column(type="text",nullable=true) + * @var string */ private $address; /** + * The URL * @Column(type="string",nullable=true) + * @var string */ private $url; /** + * The email * @Column(type="string",nullable=true) + * @var string */ private $email; /** - * @Column(type="string",nullable=true) + * The comment + * @Column(type="text",nullable=true) + * @var string */ private $comment; /** + * The phone number * @Column(type="string",nullable=true) + * @var string */ private $phone; /** + * The fax number * @Column(type="string",nullable=true) + * @var string */ private $fax; /** + * All ic logos of this manufacturer * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo",mappedBy="manufacturer",cascade={"persist", "remove"}) */ private $icLogos; + /** + * Creates a new manufacturer instance + */ public function __construct () { $this->icLogos = new \Doctrine\Common\Collections\ArrayCollection(); } + + /** + * Sets the name + * @param string $name The name + */ public function setName ($name) { $this->name = $name; } + /** + * Returns the name + * @return string The name + */ public function getName () { return $this->name; } + /** + * Sets the phone number + * @param string $phone The phone number + */ public function setPhone ($phone) { $this->phone = $phone; } + /** + * Returns the phone number + * @return string The phone number + */ public function getPhone () { return $this->phone; } + /** + * Sets the fax number + * @param string $fax The fax number + */ public function setFax ($fax) { $this->fax = $fax; } - public function getFax ($fax) { + /** + * Returns the fax number + * @return string The fax number + */ + public function getFax () { return $this->fax; } + /** + * Sets the address + * @param string $address The address + */ public function setAddress ($address) { $this->address = $address; } + /** + * Returns the address + * @return string The address + */ public function getAddress () { return $this->address; } + /** + * Sets the comment + * @param string $comment The comment + */ public function setComment ($comment) { $this->comment = $comment; } + /** + * Returns the comment + * @return string The comment + */ public function getComment () { return $this->comment; } + /** + * Sets the email + * @param string $email The email + */ public function setEmail ($email) { $this->email = $email; } + /** + * Returns the email + * @return string The email + */ public function getEmail () { return $this->email; } + /** + * Sets the URL + * @param string $url The URL + */ public function setURL ($url) { $this->url = $url; } + /** + * Returns the URL + * @return string The url + */ public function getURL () { return $this->url; } + /** + * Returns the ic logos + * @return ArrayCollection The array with all ic logos + */ public function getICLogos () { return $this->icLogos; } - public function getId () { - return $this->id; - } - + /** + * Returns this manufacturer in serialized form + * @return array The serialized manufacturer + */ public function serialize () { return array( "id" => $this->getId(), @@ -131,8 +208,4 @@ class Manufacturer { "comment" => $this->getComment() ); } - - public static function loadById ($id) { - return PartKeepr::getEM()->find(get_called_class(), $id); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerICLogo.php b/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerICLogo.php @@ -1,25 +1,52 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Manufacturer; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\Image\Image; -/** @Entity **/ -class ManufacturerICLogo extends Image { +/** + * Holds a manufacturer IC logo + * @Entity + **/ +class ManufacturerICLogo extends Image implements Serializable { /** + * The manufacturer object * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Manufacturer\Manufacturer") + * @var Manufacturer */ private $manufacturer = null; - + + /** + * Creates a new IC logo instance + */ public function __construct () { parent::__construct(Image::IMAGE_ICLOGO); } - + + /** + * Sets the manufacturer + * @param Manufacturer $manufacturer The manufacturer to set + */ public function setManufacturer (Manufacturer $manufacturer) { $this->manufacturer = $manufacturer; } + /** + * Returns the manufacturer + * @return Manufacturer the manufacturer + */ + public function getManufacturer () { + return $this->manufacturer; + } + + /** + * + * Serializes this ic logo + * @return array The serialized ic logo + */ public function serialize () { - return array("id" => $this->id, "manufacturer_id" => $this->manufacturer->getId()); + return array("id" => $this->getId(), "manufacturer_id" => $this->getMenufacturer()->getId()); } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerManager.php b/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerManager.php @@ -9,6 +9,15 @@ use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Manufacturer\Exceptions\ManufacturerNotFoundException; class ManufacturerManager extends Singleton { + /** + * Returns a list of manufacturers. + * + * @param int $start Start of the list, default 0 + * @param int $limit Number of users to list, default 10 + * @param string $sort The field to sort by, default "name" + * @param string $dir The direction to sort (ASC or DESC), default ASC + * @param string $filter A string to filter the manufacturer's name by, default empty + */ public function getManufacturers ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { $qb = PartKeepr::getEM()->createQueryBuilder(); @@ -45,16 +54,10 @@ class ManufacturerManager extends Singleton { return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); } - public function getManufacturer ($id) { - $manufacturer = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Manufacturer\Manufacturer", $id); - - if ($manufacturer) { - return $manufacturer; - } else { - throw new ManufacturerNotFoundException(); - } - } - + /** + * Adds a new manufacturer by name + * @param string $name The manufacturer name + */ public function addManufacturer ($name) { $manufacturer = new Manufacturer(); $manufacturer->setName($name); @@ -64,8 +67,20 @@ class ManufacturerManager extends Singleton { return $manufacturer; } + + /** + * Loads a manufacturer by id + * @param int $id The manufacturer id + */ + public function getManufacturer ($id) { + return Manufacturer::loadById($id); + } + /** + * Deletes the manufacturer by id + * @param int $id The manufacturer's id + */ public function deleteManufacturer ($id) { - $manufacturer = $this->getManufacturer($id); + $manufacturer = Manufacturer::loadById($id); PartKeepr::getEM()->remove($manufacturer); PartKeepr::getEM()->flush(); diff --git a/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerService.php b/src/de/RaumZeitLabor/PartKeepr/Manufacturer/ManufacturerService.php @@ -11,7 +11,11 @@ use de\RaumZeitLabor\PartKeepr\Part\PartManager, de\RaumZeitLabor\PartKeepr\Session\SessionManager; class ManufacturerService extends Service implements RestfulService { - public function get () { + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::get() + */ + public function get () { if ($this->hasParameter("id")) { return ManufacturerManager::getInstance()->getManufacturer($this->getParameter("id"))->serialize(); } else { @@ -33,6 +37,10 @@ class ManufacturerService extends Service implements RestfulService { } } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() + */ public function create () { $this->requireParameter("name"); @@ -46,6 +54,10 @@ class ManufacturerService extends Service implements RestfulService { return array("data" => $manufacturer->serialize()); } + /** + * Sets the data for the manufacturer. + * @param Manufacturer $manufacturer The manufacturer to process + */ private function setManufacturerData (Manufacturer $manufacturer) { $manufacturer->setName($this->getParameter("name")); $manufacturer->setComment($this->getParameter("comment", "")); @@ -54,6 +66,10 @@ class ManufacturerService extends Service implements RestfulService { $manufacturer->setEmail($this->getParameter("email", "")); } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::update() + */ public function update () { $this->requireParameter("id"); $this->requireParameter("name"); @@ -66,6 +82,10 @@ class ManufacturerService extends Service implements RestfulService { } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::destroy() + */ public function destroy () { $this->requireParameter("id"); @@ -73,69 +93,4 @@ class ManufacturerService extends Service implements RestfulService { return array("data" => null); } - - - // Old stuff below - public function getManufacturers() { - return ManufacturerManager::getInstance()->getManufacturers( - $this->getParameter("start", 0), - $this->getParameter("limit", 10), - $this->getParameter("sortby", "name"), - $this->getParameter("dir", "asc"), - $this->getParameter("filter", "")); - } - - public function addManufacturer () { - $this->requireParameter("name"); - - ManufacturerManager::getInstance()->addManufacturer($this->getParameter("name")); - } - - public function deleteManufacturer () { - $this->requireParameter("id"); - - ManufacturerManager::getInstance()->deleteManufacturer($this->getParameter("id")); - } - - public function deleteManufacturerLogo () { - $this->requireParameter("id"); - - $logo = ManufacturerICLogo::loadById($this->getParameter("id")); - - PartKeepr::getEM()->remove($logo); - PartKeepr::getEM()->flush(); - } - - public function getManufacturerLogos () { - $this->requireParameter("id"); - $manufacturer = ManufacturerManager::getInstance()->getManufacturer($this->getParameter("id")); - - $aData = array(); - - foreach ($manufacturer->getICLogos() as $logo) { - $aData[] = array("id" => $logo->getId()); - } - - return array("logos" => $aData); - - } - - public function getManufacturer () { - $this->requireParameter("id"); - - return ManufacturerManager::getInstance()->getManufacturer($this->getParameter("id"))->serialize(); - } - - public function saveManufacturer () { - $this->requireParameter("id"); - $this->requireParameter("name"); - - $Manufacturer = ManufacturerManager::getInstance()->getManufacturer($this->getParameter("id")); - - $Manufacturer->setName($this->getParameter("name")); - - PartKeepr::getEM()->flush(); - - return $Manufacturer->serialize(); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoManager.php b/src/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoManager.php @@ -8,6 +8,15 @@ use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Manufacturer\Exceptions\ManufacturerNotFoundException; class ManufacturerICLogoManager extends Singleton { + /** + * Returns a list of manufacturer ic logos. + * + * @param int $start Start of the list, default 0 + * @param int $limit Number of users to list, default 10 + * @param string $sort The field to sort by, default "name" + * @param string $dir The direction to sort (ASC or DESC), default ASC + * @param string $filter The manufacturer id + */ public function getManufacturerICLogos ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { $qb = PartKeepr::getEM()->createQueryBuilder(); @@ -46,29 +55,12 @@ class ManufacturerICLogoManager extends Singleton { return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult()); } + /** + * Returns a manufacturer ic logo by id + * @param int $id The manufacturer ic logo id + */ public function getManufacturerICLogo ($id) { - $manufacturer = PartKeepr::getEM()->find("de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo", $id); - - if ($manufacturer) { - return $manufacturer; - } else { - throw new ManufacturerNotFoundException(); - } - } - - public function addManufacturerICLogo ($name) { - $manufacturer = new ManufacturerICLogo(); - $manufacturer->setName($name); - - PartKeepr::getEM()->persist($manufacturer); - PartKeepr::getEM()->flush(); - - return $manufacturer; - } - public function deleteManufacturer ($id) { - $manufacturer = $this->getManufacturer($id); - - PartKeepr::getEM()->remove($manufacturer); - PartKeepr::getEM()->flush(); + return ManufacturerICLogo::loadById($id); } + } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoService.php b/src/de/RaumZeitLabor/PartKeepr/ManufacturerICLogo/ManufacturerICLogoService.php @@ -2,7 +2,7 @@ namespace de\RaumZeitLabor\PartKeepr\ManufacturerICLogo; use de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo; -use de\RaumZeitLabor\PartKeepr\Image\TempImage; +use de\RaumZeitLabor\PartKeepr\TempImage\TempImage; use de\RaumZeitLabor\PartKeepr\Service\RestfulService; @@ -14,7 +14,11 @@ use de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Session\SessionManager; class ManufacturerICLogoService extends Service implements RestfulService { - public function get () { + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::get() + */ + public function get () { if ($this->hasParameter("id")) { return ManufacturerICLogoManager::getInstance()->getManufacturerICLogo($this->getParameter("id"))->serialize(); } else { @@ -52,6 +56,10 @@ class ManufacturerICLogoService extends Service implements RestfulService { } } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::create() + */ public function create () { $this->requireParameter("tmp_id"); $this->requireParameter("manufacturer_id"); @@ -70,10 +78,18 @@ class ManufacturerICLogoService extends Service implements RestfulService { return $image->serialize(); } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::update() + */ public function update () { } + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Service.RestfulService::destroy() + */ public function destroy () { $this->requireParameter("id"); diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/Part.php b/src/de/RaumZeitLabor/PartKeepr/Part/Part.php @@ -1,87 +1,110 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Part; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Util\Exceptions\OutOfRangeException; -/** @Entity **/ -class Part { - - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var integer - */ - private $id; - +/** + * Represents a part in the database. The heart of our project. Handle with care! + * @Entity **/ +class Part extends BaseEntity implements Serializable { /** - * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Category\Category") + * The category of the part + * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Category\Category") + * @var Category */ private $category; /** + * The part's name * @Column + * @var string */ private $name; /** + * The footprint of this part * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Footprint\Footprint") + * @var Footprint */ private $footprint; /** + * The unit in which the part's "amount" is calculated. This is necessary to count parts + * in "pieces", "meters" or "grams". * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Part\PartUnit") + * @var PartUnit */ private $partUnit; /** + * Defines the storage location of this part * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\StorageLocation\StorageLocation") + * @var StorageLocation */ private $storageLocation; /** + * Holds the manufacturers which can manufacture this part * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\Part\PartManufacturer",mappedBy="part",cascade={"persist", "remove"}) + * @var ArrayCollection */ private $manufacturers; /** + * Holds the distributors from where we can buy the part * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\Part\PartDistributor",mappedBy="part",cascade={"persist", "remove"}) + * @var ArrayCollection */ private $distributors; /** + * The comment for this part * @Column(type="text") */ private $comment; /** - * The stock level. Note that this is a cached value. + * The stock level. Note that this is a cached value, because it makes our summary queries easier. + * @todo It would be nice if we could get rid of that. * @Column(type="integer") + * @var integer */ private $stockLevel = 0; /** + * The minimum stock level for this part. If we run out of this part (e.g. stockLevel < minStockLevel), + * we can see that in the system and re-order parts. + * * @Column(type="integer") + * @var integer */ private $minStockLevel; /** * The average price for the part. Note that this is a cached value. * + * @todo It would be nice if we could get rid of that * @Column(type="decimal",precision=5, scale=2,nullable=true) * @var float */ private $averagePrice = null; /** + * The stock level history * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\Stock\StockEntry",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ private $stockLevels; /** + * The parameters for this part * @OneToMany(targetEntity="de\RaumZeitLabor\PartKeepr\PartParameter\PartParameter",mappedBy="part",cascade={"persist", "remove"}) * @var ArrayCollection */ @@ -93,6 +116,18 @@ class Part { $this->parameters = new \Doctrine\Common\Collections\ArrayCollection(); } + /** + * Sets the name for this part + * @param string $name The part's name + */ + public function setName ($name) { + $this->name = $name; + } + + /** + * Returns the name of this part + * @return string The part name + */ public function getName () { return $this->name; } @@ -117,14 +152,30 @@ class Part { return $this->partUnit; } + /** + * Sets the average price for this unit + * @todo Is this actually used? + * @param float $price The price to set + */ public function setAveragePrice ($price) { $this->averagePrice = $price; } + /** + * Updates the internal stock level from the stock history + */ public function updateStockLevel () { $this->stockLevel = $this->getStockLevel(); } - + + /** + * Set the minimum stock level for this part + * + * Only positive values are allowed. + * + * @param int $minStockLevel A minimum stock level, only values >= 0 are allowed. + * @throws \de\RaumZeitLabor\PartKeepr\Util\Exceptions\OutOfRangeException If the passed stock level is not in range (>=0) + */ public function setMinStockLevel ($minStockLevel) { $minStockLevel = intval($minStockLevel); @@ -136,30 +187,58 @@ class Part { $this->minStockLevel = $minStockLevel; } + /** + * Sets the category for this part + * @param \de\RaumZeitLabor\PartKeepr\Category\Category $category The category + */ public function setCategory (\de\RaumZeitLabor\PartKeepr\Category\Category $category) { $this->category = $category; } + /** + * Sets the storage location for this part + * @param \de\RaumZeitLabor\PartKeepr\StorageLocation\StorageLocation $storageLocation The storage location + */ public function setStorageLocation (\de\RaumZeitLabor\PartKeepr\StorageLocation\StorageLocation $storageLocation) { $this->storageLocation = $storageLocation; } - public function setName ($name) { - $this->name = $name; - } - + /** + * Sets the footprint for this part + * @param \de\RaumZeitLabor\PartKeepr\Footprint\Footprint $footprint The footprint to set + */ public function setFootprint (\de\RaumZeitLabor\PartKeepr\Footprint\Footprint $footprint = null) { $this->footprint = $footprint; } + /** + * Sets the comment for this part + * @param string $comment The comment for this part + */ public function setComment ($comment) { $this->comment = $comment; } + /** + * Returns the comment for this part + * @return string The comment + */ + public function getComment () { + return $this->comment; + } + + /** + * Returns the distributors array + * @return ArrayCollection the distributors + */ public function getDistributors () { return $this->distributors; } + /** + * Returns the manufacturers array + * @return ArrayCollection the manufactuers + */ public function getManufacturers () { return $this->manufacturers; } @@ -172,18 +251,22 @@ class Part { return $this->parameters; } + /** + * Returns the stock level of this part. This is a realtime function which + * actually creates a query over the StockEntry table. + * @return int The stock level + */ public function getStockLevel () { $query = PartKeepr::getEM()->createQuery("SELECT SUM(s.stockLevel) FROM de\RaumZeitLabor\PartKeepr\Stock\StockEntry s WHERE s.part = :part"); $query->setParameter("part", $this); return $query->getSingleScalarResult(); - - } - - public function getId () { - return $this->id; } - + + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Util.Serializable::serialize() + */ public function serialize () { $aManufacturers = array(); @@ -203,9 +286,9 @@ class Part { } return array( - "id" => $this->id, - "name" => $this->name, - "comment" => $this->comment, + "id" => $this->getId(), + "name" => $this->getName(), + "comment" => $this->getComment(), "stockLevel" => $this->getStockLevel(), "footprint_id" => is_object($this->footprint) ? $this->footprint->getId() : null, "minStockLevel" => $this->minStockLevel, diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartDistributor.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartDistributor.php @@ -1,19 +1,18 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Part; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Distributor\Distributor; -/** @Entity **/ -class PartDistributor { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var unknown_type - */ - private $id; - +/** + * This class represents the link between a part and a distributor. + * @Entity **/ +class PartDistributor extends BaseEntity implements Serializable { /** * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Part\Part") */ @@ -25,20 +24,27 @@ class PartDistributor { private $distributor; /** + * The order number for the part and distributor * @Column(type="string",nullable=true) - * Enter description here ... - * @var unknown_type + * @var string */ private $orderNumber; /** + * Defines the packaging unit when ordering a part. Some items can't be ordered in a quantity of just one at + * certain manufacturers. + * * @Column(type="integer") * @var integer - * - * Defines the packaging unit when ordering a part. */ private $packagingUnit; + /** + * Cretes a new part->distributor link. Initializes the packaging unit with a quantity of "1". + * + * @param Part $part The part + * @param Distributor $distributor The distributor + */ public function __construct (Part $part, Distributor $distributor) { $this->setPart($part); $this->setDistributor($distributor); @@ -68,38 +74,66 @@ class PartDistributor { $this->packagingUnit = $packagingUnit; } + /** + * Returns the packaging unit + * @return int The packaging unit + */ public function getPackagingUnit () { return $this->packagingUnit; } + /** + * Sets the part + * @param Part $part The part + */ public function setPart (Part $part) { $this->part = $part; } + /** + * Returns the part + * @return Part The part + */ public function getPart () { return $this->part; } + /** + * Sets the distributor + * @param Distributor $distributor The distributor + */ public function setDistributor (Distributor $distributor) { $this->distributor = $distributor; } + /** + * Returns the distributor + * @return Distributor The distributor + */ public function getDistributor () { return $this->distributor; } + /** + * Sets the order number + * @param string $orderNumber The order number + */ public function setOrderNumber ($orderNumber) { $this->orderNumber = $orderNumber; } + /** + * Returns the order number + * @return string The order number + */ public function getOrderNumber () { return $this->orderNumber; } - - public function getId () { - return $this->id; - } - + + /** + * (non-PHPdoc) + * @see de\RaumZeitLabor\PartKeepr\Util.Serializable::serialize() + */ public function serialize () { return array( "id" => $this->getId(), diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartManager.php @@ -26,10 +26,14 @@ use de\RaumZeitLabor\PartKeepr\Util\Singleton, de\RaumZeitLabor\PartKeepr\Footprint\Footprint, de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Category\CategoryManager, - de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerManager, - de\RaumZeitLabor\PartKeepr\Footprint\Exceptions\FootprintNotFoundException; + de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerManager; class PartManager extends Singleton { + /** + * Returns a list of parts. + * + * @todo The parameter list. We need to invent something so that we don't have like 20 parameters for this method. + */ public function getParts ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "", $category = 0, $categoryScope = "all", $stockMode = "all", $withoutPrice = false, $storageLocation = "") { $qb = PartKeepr::getEM()->createQueryBuilder(); @@ -55,7 +59,7 @@ class PartManager extends Singleton { $orderBy = "st.name"; break; case "footprintName": - $orderBy = "f.footprint"; + $orderBy = "f.name"; break; default; $orderBy = "p.".$sort; @@ -102,7 +106,7 @@ class PartManager extends Singleton { - $qb->select("p.averagePrice, p.name, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, st.name as storageLocationName, f.id AS footprint_id, f.footprint AS footprintName, c.id AS category_id, c.name AS categoryName, pu.name AS partUnit, pu.is_default AS partUnitDefault"); + $qb->select("p.averagePrice, p.name, p.id, p.stockLevel, p.minStockLevel, p.comment, st.id AS storageLocation_id, st.name as storageLocationName, f.id AS footprint_id, f.name AS footprintName, c.id AS category_id, c.name AS categoryName, pu.name AS partUnit, pu.is_default AS partUnitDefault"); $qb->orderBy($orderBy, $dir); if ($limit > -1) { $qb->setMaxResults($limit); diff --git a/src/de/RaumZeitLabor/PartKeepr/Part/PartManufacturer.php b/src/de/RaumZeitLabor/PartKeepr/Part/PartManufacturer.php @@ -1,19 +1,16 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Part; +use de\RaumZeitLabor\PartKeepr\Util\Serializable; + +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Manufacturer\Manufacturer; /** @Entity **/ -class PartManufacturer { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var unknown_type - */ - private $id; - +class PartManufacturer extends BaseEntity implements Serializable { /** * @ManyToOne(targetEntity="de\RaumZeitLabor\PartKeepr\Part\Part") */ @@ -60,10 +57,6 @@ class PartManufacturer { return $this->partNumber; } - public function getId () { - return $this->id; - } - /** * Returns the data of this object in a serialized form. * @return array The result array diff --git a/src/de/RaumZeitLabor/PartKeepr/PartDistributor/PartDistributorService.php b/src/de/RaumZeitLabor/PartKeepr/PartDistributor/PartDistributorService.php @@ -2,8 +2,6 @@ namespace de\RaumZeitLabor\PartKeepr\ManufacturerICLogo; use de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo; -use de\RaumZeitLabor\PartKeepr\Image\TempImage; - use de\RaumZeitLabor\PartKeepr\Service\RestfulService; declare(encoding = 'UTF-8'); @@ -43,6 +41,7 @@ class PartDistributorService extends Service implements RestfulService { } } } + // @todo This seems wrong?!? return ManufacturerICLogoManager::getInstance()->getManufacturerICLogos( $this->getParameter("start", $this->getParameter("start", 0)), $this->getParameter("limit", $this->getParameter("limit", 25)), diff --git a/src/de/RaumZeitLabor/PartKeepr/PartKeepr.php b/src/de/RaumZeitLabor/PartKeepr/PartKeepr.php @@ -184,7 +184,7 @@ class PartKeepr { 'de\RaumZeitLabor\PartKeepr\Distributor\Distributor', 'de\RaumZeitLabor\PartKeepr\Image\Image', 'de\RaumZeitLabor\PartKeepr\Image\CachedImage', - 'de\RaumZeitLabor\PartKeepr\Image\TempImage', + 'de\RaumZeitLabor\PartKeepr\TempImage\TempImage', 'de\RaumZeitLabor\PartKeepr\Manufacturer\ManufacturerICLogo', 'de\RaumZeitLabor\PartKeepr\Statistic\StatisticSnapshot', 'de\RaumZeitLabor\PartKeepr\Statistic\StatisticSnapshotUnit', diff --git a/src/de/RaumZeitLabor/PartKeepr/SiPrefix/SiPrefix.php b/src/de/RaumZeitLabor/PartKeepr/SiPrefix/SiPrefix.php @@ -1,5 +1,7 @@ <?php namespace de\RaumZeitLabor\PartKeepr\SiPrefix; +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, @@ -7,14 +9,7 @@ use de\RaumZeitLabor\PartKeepr\PartKeepr, /** @Entity **/ -class SiPrefix { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var integer - */ - private $id; - +class SiPrefix extends BaseEntity { /** * The prefix of the Si-Prefix (e.g. yotta, deca, deci, centi) * @Column(type="string") @@ -85,15 +80,6 @@ class SiPrefix { } /** - * Returns the ID for this object. - * @param none - * @return int The ID for this object - */ - public function getId () { - return $this->id; - } - - /** * Serializes the object into an array format. * @return array the object in serialized format. */ @@ -104,12 +90,4 @@ class SiPrefix { "prefix" => $this->getPrefix(), "power" => $this->getPower()); } - - /** - * Loads a prefix by ID - * @param int $id The ID to load - */ - public static function loadById ($id) { - return PartKeepr::getEM()->find(get_called_class(), $id); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/TempImage/TempImage.php b/src/de/RaumZeitLabor/PartKeepr/TempImage/TempImage.php @@ -0,0 +1,20 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\TempImage; +declare(encoding = 'UTF-8'); + +use de\RaumZeitLabor\PartKeepr\Image\Exceptions\InvalidImageTypeException, + de\RaumZeitLabor\PartKeepr\Util\Configuration, + de\RaumZeitLabor\PartKeepr\Image\Image, + de\RaumZeitLabor\PartKeepr\PartKeepr; + +/** + * Represents a temporary image. Temporary images are used when + * a user uploaded an image, but not attached it to an entity. + * + * @Entity + */ +class TempImage extends Image { + public function __construct () { + parent::__construct(Image::IMAGE_TEMP); + } +}+ \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Unit/Unit.php b/src/de/RaumZeitLabor/PartKeepr/Unit/Unit.php @@ -1,5 +1,7 @@ <?php namespace de\RaumZeitLabor\PartKeepr\Unit; +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, @@ -12,14 +14,7 @@ use de\RaumZeitLabor\PartKeepr\PartKeepr, * * @Entity **/ -class Unit { - /** - * @Id @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - * @var integer - */ - private $id; - +class Unit extends BaseEntity { /** * The name of the unit (e.g. Volts, Ampere, Farad, Metres) * @Column(type="string") @@ -91,21 +86,4 @@ class Unit { public function getPrefixes () { return $this->prefixes; } - - /** - * Returns the ID for this object. - * @param none - * @return int The ID for this object - */ - public function getId () { - return $this->id; - } - - /** - * Loads a unit by ID - * @param int $id The ID to load - */ - public static function loadById ($id) { - return PartKeepr::getEM()->find(get_called_class(), $id); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/UploadedFile/UploadedFile.php b/src/de/RaumZeitLabor/PartKeepr/UploadedFile/UploadedFile.php @@ -1,5 +1,7 @@ <?php namespace de\RaumZeitLabor\PartKeepr\UploadedFile; +use de\RaumZeitLabor\PartKeepr\Util\BaseEntity; + declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, @@ -8,17 +10,7 @@ use de\RaumZeitLabor\PartKeepr\PartKeepr, /** * @MappedSuperclass */ -abstract class UploadedFile { - /** - * Specifies the ID of the file. - * - * @var integer - * @Id - * @Column(type="integer") - * @GeneratedValue(strategy="AUTO") - **/ - protected $id; - +abstract class UploadedFile extends BaseEntity { /** * Specifies the type of the file. * @@ -83,15 +75,6 @@ abstract class UploadedFile { } /** - * Returns the ID of the file. - * @param none - * @return integer The ID of the file - */ - public function getId () { - return $this->id; - } - - /** * Returns the size of this file * @return integer The size in bytes */ @@ -171,13 +154,4 @@ abstract class UploadedFile { mkdir($this->getFilePath(), 0777, true); } } - - /** - * Loads the file by id. - * @return int The id of the file - * @param unknown_type $id - */ - public static function loadById ($id) { - return PartKeepr::getEM()->find(get_called_class(), $id); - } } \ No newline at end of file diff --git a/src/de/RaumZeitLabor/PartKeepr/Util/Serializable.php b/src/de/RaumZeitLabor/PartKeepr/Util/Serializable.php @@ -0,0 +1,11 @@ +<?php +namespace de\RaumZeitLabor\PartKeepr\Util; + +interface Serializable { + /** + * Serializes the entity into an array format, which in turn can + * be used by json_encode. + * @return array The serialized form of the entity + */ + public function serialize (); +}+ \ No newline at end of file diff --git a/testing/SetupDatabase.php b/testing/SetupDatabase.php @@ -100,7 +100,7 @@ $r = mysql_query("SELECT * FROM footprints"); while ($sFootprint = mysql_fetch_assoc($r)) { $footprint = new Footprint(); - $footprint->setFootprint(convertText($sFootprint["name"])); + $footprint->setName(convertText($sFootprint["name"])); echo " Adding footprint ".$sFootprint["name"]."\r"; PartKeepr::getEM()->persist($footprint);