partkeepr

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

commit 44eaae0784c2a4f1ea73075072fa834f8c168bf7
parent 26cf96896c3adfa50ee536d1ac5a59ce55f8fb4d
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri, 17 Jul 2015 19:48:37 +0200

Removed printing functionality, this needs to be reimplemented in a proper way later

Diffstat:
Dsrc/backend/PartKeepr/Printing/Exceptions/InvalidArgumentException.php | 16----------------
Dsrc/backend/PartKeepr/Printing/Exceptions/RendererNotFoundException.php | 16----------------
Dsrc/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php | 313-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutManager.php | 58----------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutService.php | 66------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php | 153-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJob/PrintingJobManager.php | 54------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJob/PrintingJobService.php | 105-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php | 195-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationManager.php | 60------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationService.php | 88-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/PrintingService.php | 160-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/RendererFactoryIfc.php | 47-----------------------------------------------
Dsrc/backend/PartKeepr/Printing/RendererFactoryRegistry.php | 108-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/RendererIfc.php | 34----------------------------------
Dsrc/backend/PartKeepr/Printing/SimpleRendererFactory.php | 107-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/Utils/DecodeConfiguration.php | 33---------------------------------
Dsrc/backend/PartKeepr/Printing/Utils/PercentOrNumericHelper.php | 101-------------------------------------------------------------------------------
Dsrc/backend/PartKeepr/Printing/Utils/Placeholder.php | 93-------------------------------------------------------------------------------
Dsrc/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/PDFDefaultRenderer.php | 233-------------------------------------------------------------------------------
Dsrc/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/TCPDFAbstractRenderer.php | 205-------------------------------------------------------------------------------
Dsrc/backend/Plugins/PrintingRenderer/ZebraLabelWriterRenderer/ZebraLabelWriterRenderer.php | 165-------------------------------------------------------------------------------
22 files changed, 0 insertions(+), 2410 deletions(-)

diff --git a/src/backend/PartKeepr/Printing/Exceptions/InvalidArgumentException.php b/src/backend/PartKeepr/Printing/Exceptions/InvalidArgumentException.php @@ -1,15 +0,0 @@ -<?php -namespace PartKeepr\Printing\Exceptions; - -use PartKeepr\Util\SerializableException; - -/** - * Illeagal argument Expression. - * Will be thrown to indicate an error which was caused by invalid arguments. - */ -class InvalidArgumentException extends SerializableException { - public function __construct ($detailedReason) { - parent::__construct( $detailedReason ); - } -} -?>- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/Exceptions/RendererNotFoundException.php b/src/backend/PartKeepr/Printing/Exceptions/RendererNotFoundException.php @@ -1,15 +0,0 @@ -<?php -namespace PartKeepr\Printing\Exceptions; - -use PartKeepr\Util\SerializableException, - PartKeepr\PartKeepr; - -/** - * Expression will be thrown if a requested renderer was not found. - */ -class RendererNotFoundException extends SerializableException { - public function __construct ($detailedReason, $requestedClass, $availableClasses) { - parent::__construct(PartKeepr::i18n("No adequate renderer found: $detailedReason \nRequested: $requestedClass \nAvailable: ".implode(", ",$availableClasses))); - } -} -?>- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php b/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayout.php @@ -1,313 +0,0 @@ -<?php -namespace PartKeepr\Printing\PageBasicLayout; - -use PartKeepr\Util\BaseEntity, - PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable, - Doctrine\ORM\Mapping as ORM; - -/** - * This class is a layout which can be used to describe a typical page - * which has a n*m cell table on it. Such a table is interesting for e.g. if - * one will print labels. - * - * The layout of such a page needs: - * - Paper size - * - TopLeft position on page - * - Width and height of the cells (every cell has the same size) - * - Number of cells in columns an rows. - * - * @ORM\Entity - */ -class PageBasicLayout extends BaseEntity implements Serializable, Deserializable { - /** - * The name of this layout. - * @ORM\Column(type="text") - */ - private $name; - - /** - * The comment for this layout. - * @ORM\Column(type="text") - */ - private $comment; - - /** - * The numbers of columns on the page - * @ORM\Column(type="integer") - * @var integer - */ - private $columnCount = 1; - - /** - * The numbers of rows on the page - * @ORM\Column(type="integer") - * @var integer - */ - private $rowCount = 1; - - /** - * The size of the entire paper - * - * @ORM\Column(type="text") - */ - private $paperSize = "A4"; - - /** - * Indicates the orientation of the paper or better, the orientation - * of the final text. - * @ORM\Column(type="boolean") - */ - private $paperPortrait = true; - - /** - * This is the cell width in mm. - * @ORM\Column(type="float") - * @var float - */ - private $cellWidthInMM = 100; - - /** - * This is the cell height in mm. - * @ORM\Column(type="float") - * @var float - */ - private $cellHeightInMM = 100; - - /** - * This is the top left X position of the first cell on the - * sheet. - * @ORM\Column(type="float") - * @var float - */ - private $topLeftXInMM = 0; - - /** - * This is the top left Y position of the first cell on the - * sheet. - * @ORM\Column(type="float") - * @var float - */ - private $topLeftYInMM = 0; - - /** - * Sets name. - * @param string $name - */ - public function setName( $name ){ - $this->name = $name; - } - - /** - * Retrives name. - * @return string - */ - public function getName(){ - return $this->name; - } - - /** - * Sets the comment. - * @param unknown $comment - */ - public function setComment( $comment ){ - $this->comment = $comment; - } - - /** - * Retrieve comment. - * @return unknown - */ - public function getComment(){ - return $this->comment; - } - - /** - * Sets column count. - * @param unknown $count - */ - public function setColumnCount( $count ){ - $this->columnCount = $count; - } - - /** - * Retrieve column count. - * @return number - */ - public function getColumnCount(){ - return $this->columnCount; - } - - /** - * Sets row count. - * @param unknown $count - */ - public function setRowCount( $count ){ - $this->rowCount = $count; - } - - /** - * Retrieve row count. - * @return number - */ - public function getRowCount(){ - return $this->rowCount; - } - - /** - * Sets paper size - * @param unknown $size - */ - public function setPaperSize( $size ){ - $this->paperSize = $size; - } - - /** - * Retrieve paper size. - * @return string - */ - public function getPaperSize(){ - return $this->paperSize; - } - - /** - * Sets Paper portrait. - * @param unknown $portrait - */ - public function setPaperPortrait( $portrait ){ - $this->paperPortrait = $portrait; - } - - /** - * Retrieves paper portrait. - * @return boolean - */ - public function getPaperPortrait(){ - return $this->paperPortrait; - } - - /** - * Sets cell width in mm - * @param unknown $size - */ - public function setCellWidthInMM( $size ){ - $this->cellWidthInMM = $size; - } - - /** - * Retrieves cell width in mm. - * @return number - */ - public function getCellWidthInMM( ){ - return $this->cellWidthInMM; - } - - /** - * Sets cell height in mm - * @param unknown $size - */ - public function setCellHeightInMM( $size ){ - $this->cellHeightInMM = $size; - } - - /** - * retrieves cell height in mm. - * @return number - */ - public function getCellHeightInMM( ){ - return $this->cellHeightInMM; - } - - /** - * Sets top left position x in mm. - * @param unknown $pos - */ - public function setTopLeftXInMM( $pos ){ - $this->topLeftXInMM = $pos; - } - - /** - * Gets top left position x in mm. - * @return number - */ - public function getTopLeftXInMM(){ - return $this->topLeftXInMM; - } - - /** - * Sets top left position y in mm. - * @param unknown $pos - */ - public function setTopLeftYInMM( $pos ){ - $this->topLeftYInMM = $pos; - } - - /** - * Retrieves top left y position in mm. - * @return number - */ - public function getTopLeftYInMM(){ - return $this->topLeftYInMM; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Util\Serializable::serialize() - */ - public function serialize () { - return array( - "id" => $this->getId(), - "name" => $this->getName(), - "comment" => $this->getComment(), - "columnCount" => $this->getColumnCount(), - "rowCount" => $this->getRowCount(), - "paperSize" => $this->getPaperSize(), - "paperPortrait" => $this->getPaperPortrait(), - "cellWidthInMM" => $this->getCellWidthInMM(), - "cellHeightInMM" => $this->getCellHeightInMM(), - "topLeftXInMM" => $this->getTopLeftXInMM(), - "topLeftYInMM" => $this->getTopLeftYInMM() - ); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Util\Deserializable::deserialize() - */ - public function deserialize (array $parameters) { - foreach ($parameters as $key => $value) { - switch ($key) { - case "name": - $this->setName( $value); - break; - case "comment": - $this->setComment($value); - break; - case "columnCount": - $this->setColumnCount($value); - break; - case "rowCount": - $this->setRowCount($value); - break; - case "paperSize": - $this->setPaperSize($value); - break; - case "paperPortrait": - $this->setPaperPortrait($value); - break; - case "cellWidthInMM": - $this->setCellWidthInMM($value); - break; - case "cellHeightInMM": - $this->setCellHeightInMM($value); - break; - case "topLeftXInMM": - $this->setTopLeftXInMM($value); - break; - case "topLeftYInMM": - $this->setTopLeftYInMM($value); - break; - } - } - } -} diff --git a/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutManager.php b/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutManager.php @@ -1,57 +0,0 @@ -<?php -namespace PartKeepr\Printing\PageBasicLayout; - -use PartKeepr\PartKeepr, - PartKeepr\Printing\PageBasicLayout\PrintingPageBasicLayout, - PartKeepr\Util\Singleton, - PartKeepr\Util\Exceptions\ObjectNotFoundException; - -class PageBasicLayoutManager extends Singleton { - public function getMultipleObjects ($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "") { - $qb = PartKeepr::getEM()->createQueryBuilder(); - $qb->select("st.id, st.name")->from("PartKeepr\Printing\PageBasicLayout\PageBasicLayout","st"); - - if ($filter != "") { - $qb = $qb->where("LOWER(st.name) LIKE :filter"); - $qb->setParameter("filter", "%".strtolower($filter)."%"); - } - - if ($limit > -1) { - $qb->setMaxResults($limit); - $qb->setFirstResult($start); - } - - $qb->orderBy("st.".$sort, $dir); - - $query = $qb->getQuery(); - - $result = $query->getResult(); - - $totalQueryBuilder = PartKeepr::getEM()->createQueryBuilder(); - $totalQueryBuilder->select("COUNT(st.id)")->from("PartKeepr\Printing\PageBasicLayout\PageBasicLayout","st"); - - if ($filter != "") { - $totalQueryBuilder = $totalQueryBuilder->where("LOWER(st.name) LIKE :filter"); - $totalQueryBuilder->setParameter("filter", "%".strtolower($filter)."%"); - } - - $totalQuery = $totalQueryBuilder->getQuery(); - - return array("data" => $result, "start" => $start, "totalCount" => $totalQuery->getSingleScalarResult()); - } - - public function getObjectById ($id) { - $obj = PartKeepr::getEM()->find("PartKeepr\Printing\PageBasicLayout\PageBasicLayout", $id); - if ($obj) { - return $obj; - } else { - throw new ObjectNotFoundException("PartKeepr\Printing\PageBasicLayout\PageBasicLayout", $id); - } - } - public function deleteObjectById ($id) { - $obj = $this->getObjectById($id); - - PartKeepr::getEM()->remove($obj); - PartKeepr::getEM()->flush(); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutService.php b/src/backend/PartKeepr/Printing/PageBasicLayout/PageBasicLayoutService.php @@ -1,65 +0,0 @@ -<?php -namespace PartKeepr\Printing\PageBasicLayout; - -use PartKeepr\Service\RestfulService, - PartKeepr\Service\Service, - PartKeepr\Printing\PageBasicLayout\PageBasicLayout, - PartKeepr\Printing\PageBasicLayout\PageBasicLayoutManager, - PartKeepr\PartKeepr; - -class PageBasicLayoutService extends Service implements RestfulService { - - public function get () { - if ($this->hasParameter("id")) { - return array("data" => PageBasicLayoutManager::getInstance()->getObjectById($this->getParameter("id"))->serialize()); - } else { - if ($this->hasParameter("sort")) { - $tmp = json_decode($this->getParameter("sort"), true); - - $aSortParams = $tmp[0]; - } else { - $aSortParams = array( - "property" => "name", - "direction" => "ASC"); - } - return PageBasicLayoutManager::getInstance()->getMultipleObjects( - $this->getParameter("start", $this->getParameter("start", 0)), - $this->getParameter("limit", $this->getParameter("limit", 25)), - $this->getParameter("sortby", $aSortParams["property"]), - $this->getParameter("dir", $aSortParams["direction"]), - $this->getParameter("query", "")); - } - } - - public function create () { - $this->requireParameter("name"); - - $obj = new PageBasicLayout(); - $obj->deserialize($this->getParameters()); - - PartKeepr::getEM()->persist($obj); - PartKeepr::getEM()->flush(); - - return array("data" => $obj->serialize()); - } - - public function update () { - $this->requireParameter("id"); - $this->requireParameter("name"); - $obj = PageBasicLayoutManager::getInstance()->getObjectById($this->getParameter("id")); - $obj->deserialize($this->getParameters()); - - PartKeepr::getEM()->flush(); - - return array("data" => $obj->serialize()); - - } - - public function destroy () { - $this->requireParameter("id"); - - PageBasicLayoutManager::getInstance()->deleteObjectById($this->getParameter("id")); - - return array("data" => null); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php b/src/backend/PartKeepr/Printing/PrintingJob/PrintingJob.php @@ -1,153 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJob; - -use Doctrine\ORM\Mapping as ORM; -use PartKeepr\AuthBundle\Entity\User\User; -use PartKeepr\EventNotification\EventManager; -use PartKeepr\Session\SessionManager; -use PartKeepr\UploadedFileBundle\Entity\TempUploadedFile; -use PartKeepr\Util\BaseEntity; -use PartKeepr\Util\Serializable; - -/** - * This is a single job waiting for beeing processed. - * - * @ORM\Entity @ORM\HasLifecycleCallbacks - */ -class PrintingJob extends BaseEntity implements Serializable { - /** - * The timestamp when the job was created. - * @ORM\Column(type="datetime") - */ - private $created; - - /** - * Will be set if the job was processed successfully by somebody and is marked - * as done. - * @ORM\Column(type="boolean") - */ - private $done; - - /** - * This is the user which has created this printing job. - * @ORM\ManyToOne(targetEntity="PartKeepr\AuthBundle\Entity\User\User") - */ - private $owner; - - /** - * Target user the printing job is for. This is mostly the printer or output queue - * which should be used to process this job. - * @ORM\ManyToOne(targetEntity="PartKeepr\AuthBundle\Entity\User\User") - */ - private $target; - - /** - * Holds the data which was rendered for printing. - * @ORM\OneToOne(targetEntity="PartKeepr\UploadedFile\TempUploadedFile") - */ - private $data; - - public function __construct () { - $this->created = new \DateTime(); - $this->done = false; - $this->owner = SessionManager::getInstance()->getCurrentSession()->getUser(); - } - - /** - * This method is a callback for the PostPersist event. We will add it to our database - * dependent eventNotification. - * - * @ORM\PostPersist @ORM\PostUpdate - */ - public function onPostPersist(){ - if (!$this->done) { - EventManager::getInstance()->getOrCreateByName("Printing.pendingJob")->emit(); - } - } - - /** - * Retrieve created field. - */ - public function getCreated(){ - return $this->created; - } - - /** - * Sets done to new value. - * @param boolean $done - */ - public function setDone( $done ){ - $this->done = $done; - } - - /** - * Retrieve done field. - * @return boolean - */ - public function getDone(){ - return $this->done; - } - - /** - * Sets data field to a file. - * @param TempUploadedFile $data - */ - public function setData( TempUploadedFile $data ){ - $this->data = $data; - } - - /** - * Retrieve data file. - * @return TempUploadedFile - */ - public function getData( ){ - return $this->data; - } - - /** - * Sets the owner of this job. - * @param User $user - */ - public function setOwner( User $user ) { - $this->owner = $user; - } - - /** - * Retrieves owner of this job. - * @return User - */ - public function getOwner() { - return $this->owner; - } - - /** - * Sets the target of this job. - * @param User $user - */ - public function setTarget( User $user ){ - $this->target = $user; - } - - /** - * Retrieve target for this job. - * @return User - */ - public function getTarget() { - return $this->target; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Util\Serializable::serialize() - */ - public function serialize () { - return array( - "id" => $this->getId(), - "created" => $this->getCreated(), - "done" => $this->getDone(), - "owner" => $this->getOwner()->getId(), - "target" => $this->getTarget()->getId(), - "data" => $this->getData()->getId() - ); - } -} diff --git a/src/backend/PartKeepr/Printing/PrintingJob/PrintingJobManager.php b/src/backend/PartKeepr/Printing/PrintingJob/PrintingJobManager.php @@ -1,53 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJob; - -use Doctrine\ORM\Query, - Doctrine\ORM\QueryBuilder, - PartKeepr\Manager\AbstractManager, - PartKeepr\Manager\ManagerFilter, - PartKeepr\PartKeepr, - PartKeepr\Printing\PrintingJob\PrintingJob, - PartKeepr\Util\Singleton, - PartKeepr\Util\Exceptions\ObjectNotFoundException; - -/** - * The manager for the PrintingJob. - */ -class PrintingJobManager extends AbstractManager { - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getEntityName() - */ - public function getEntityName () { - return 'PartKeepr\Printing\PrintingJob\PrintingJob'; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getQueryFields() - */ - public function getQueryFields () { - return array("id","created","done","ow.id AS owner","ta.id AS target","da.id AS data"); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getDefaultSortField() - */ - public function getDefaultSortField () { - return "created"; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::applyCustomQuery() - */ - protected function applyCustomQuery (QueryBuilder $qb, ManagerFilter $filter) { - /** - * Pull in additional tables - */ - $qb ->leftJoin("q.target", "ta") - ->leftJoin("q.owner", "ow") - ->leftJoin("q.data", "da"); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PrintingJob/PrintingJobService.php b/src/backend/PartKeepr/Printing/PrintingJob/PrintingJobService.php @@ -1,104 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJob; - -use PartKeepr\PartKeepr, - PartKeepr\Manager\ManagerFilter, - PartKeepr\Printing\PrintingJob\PrintingJob, - PartKeepr\Printing\PrintingJob\PrintingJobManager, - PartKeepr\Service\RestfulService, - PartKeepr\Service\FilterExtractor, - PartKeepr\Service\Service, - PartKeepr\Session\SessionManager; - -/** - * This is the exposed restful service for working with the PrintingJobs. - */ -class PrintingJobService extends Service implements RestfulService { - /** - * Checks the permission and throws an exception if the access is denied. - * @throws \Exception - */ - private function checkPermission( $job ){ - $user = SessionManager::getInstance()->getCurrentSession()->getUser(); - if( !$user->isAdmin() && $user === $job->getTarget() && $user === $job->getOwner() ) - throw new \Exception("Permission denied!"); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::get() - */ - public function get () { - if ($this->hasParameter("id")) { - $job = PrintingJobManager::getInstance()->getEntity($this->getParameter("id")); - $this->checkPermission($job); - - return array("data" => $job->serialize()); - } else { - $filter = new ManagerFilter($this); - $filter->setFilterCallback(array($this, "filterCallback")); - return PrintingJobManager::getInstance()->getList($filter); - } - } - - /** - * - * @param unknown $queryBuilder - */ - public function filterCallback ($queryBuilder) { - $filter = new FilterExtractor($this); - - // Apply access restriction filters here - $user = SessionManager::getInstance()->getCurrentSession()->getUser(); - - $queryBuilder->andWhere("(q.target = :sessionuser OR q.owner = :sessionuser)"); - $queryBuilder->setParameter("sessionuser", $user->getId() ); - - // Apply User filters here - if ($filter->has("done") && $filter->get("done") != "") { - $queryBuilder->andWhere("q.done = :done"); - $queryBuilder->setParameter("done", $filter->get("done") ); - } - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::create() - */ - public function create () { - throw new \Exception("Creation of printing jobs cannot be done by this service!"); - } - - /** - * This update method only supports updating the done flag! - * @see \PartKeepr\Service\RestfulService::update() - */ - public function update () { - $this->requireParameter("id"); - $this->requireParameter("done"); - - $obj = PrintingJobManager::getInstance()->getEntity($this->getParameter("id")); - $this->checkPermission($obj); - - $obj->setDone( $this->getParameter("done")=='true'); - PartKeepr::getEM()->flush(); - - return array("data" => $obj->serialize()); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::destroy() - */ - public function destroy () { - $this->requireParameter("id"); - $id = $this->getParameter("id"); - - $job = PrintingJobManager::getInstance()->getEntity($id); - $this->checkPermission($job); - - PrintingJobManager::getInstance()->deleteEntity($id); - - return array("data" => null); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php b/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfiguration.php @@ -1,195 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJobConfiguration; - -use PartKeepr\Printing\PageBasicLayout\PageBasicLayout; - -use PartKeepr\Util\BaseEntity, - PartKeepr\Util\Deserializable, - PartKeepr\Util\Serializable, - Doctrine\ORM\Mapping as ORM; - - -/** - * This is a configuration for a specific job to export. - * Such a job is bound to a specific type to export and - * holds all additional configuration options to execute - * the job correctly. - * - * @ORM\Entity - */ -class PrintingJobConfiguration extends BaseEntity implements Serializable, Deserializable { - /** - * The name of this layout. - * @ORM\Column(type="text") - */ - private $name; - - /** - * The comment for this layout. - * @ORM\Column(type="text") - */ - private $comment; - - /** - * This holds the object type this configuration is used for. - * @ORM\Column(type="text") - */ - private $objectType; - - /** - * The classname of the export renderer. - * @ORM\Column(type="text") - */ - private $exportRenderer; - - /** - * This is the layout to use if we are in printing mode. - * @ORM\ManyToOne(targetEntity="PartKeepr\Printing\PageBasicLayout\PageBasicLayout") - */ - private $pageLayout; - - /** - * This field holds additional renderer configuration data. This configuration - * is very renderer specific and can be used to parametrize the output more. - * - * @ORM\Column(type="text") - */ - private $rendererConfiguration; - - /** - * Sets the name. - */ - public function setName( $name ){ - $this->name = $name; - } - - /** - * Retrieves the name - */ - public function getName(){ - return $this->name; - } - - /** - * Sets comment. - */ - public function setComment( $comment ){ - $this->comment = $comment; - } - - /** - * Rerieve comment. - */ - public function getComment(){ - return $this->comment; - } - - /** - * Sets object type. - */ - public function setObjectType( $type ){ - $this->objectType = $type; - } - - /** - * Retrieve object type. - */ - public function getObjectType( ){ - return $this->objectType; - } - - /** - * Sets the export renderer to use for this job. - */ - public function setExportRenderer( $rendererName ){ - $this->exportRenderer = $rendererName; - } - - /** - * Retrieve the export renderer. - */ - public function getExportRenderer(){ - return $this->exportRenderer; - } - - /** - * Sets the page layout. - */ - public function setPageLayout( $layout ){ - $this->pageLayout = $layout; - } - - /** - * Retrieves page layout. - */ - public function getPageLayout(){ - return $this->pageLayout; - } - - /** - * Set render configuration. - */ - public function setRendererConfiguration( $cfg ){ - $this->rendererConfiguration = $cfg; - } - - /** - * Retrieve render configuration. - */ - public function getRendererConfiguration(){ - return $this->rendererConfiguration; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Util\Serializable::serialize() - */ - public function serialize () { - return array( - "id" => $this->getId(), - "name" => $this->getName(), - "comment" => $this->getComment(), - "objectType" => $this->getObjectType(), - "exportRenderer" => $this->getExportRenderer(), - "pageLayout" => is_object( $this->getPageLayout() ) ? $this->getPageLayout()->getId(): null, - "rendererConfiguration" => $this->getRendererConfiguration() - ); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Util\Deserializable::deserialize() - */ - public function deserialize (array $parameters) { - foreach ($parameters as $key => $value) { - switch ($key) { - case "name": - $this->setName( $value); - break; - case "comment": - $this->setComment($value); - break; - case "objectType": - $this->setObjectType($value); - break; - case "exportRenderer": - $this->setExportRenderer($value); - break; - case "pageLayout": - if ($value === 0) { - $this->setPageLayout(null); - } else { - try { - $this->setPageLayout( PageBasicLayout::loadById($value) ); - } catch (\Exception $e) { - $this->setPageLayout(null); - } - } - break; - case "rendererConfiguration": - $this->setRendererConfiguration($value); - break; - } - } - } -} diff --git a/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationManager.php b/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationManager.php @@ -1,59 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJobConfiguration; - -use PartKeepr\Manager\AbstractManager, - PartKeepr\PartKeepr, - PartKeepr\Printing\PrintingJobConfiguration\PrintingPrintingJobConfiguration, - PartKeepr\Util\Singleton, - PartKeepr\Util\Exceptions\ObjectNotFoundException; - -/** - * This is the manager for our printing job configurations. - */ -class PrintingJobConfigurationManager extends AbstractManager { - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getEntityName() - */ - public function getEntityName () { - return 'PartKeepr\Printing\PrintingJobConfiguration\PrintingJobConfiguration'; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getQueryFields() - */ - public function getQueryFields () { - return array("id", "name", "comment", "objectType", "exportRenderer", "rendererConfiguration"); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Manager\AbstractManager::getDefaultSortField() - */ - public function getDefaultSortField () { - return "name"; - } - - /** - * Removes a configuration with the given id from the database. - * @param unknown $id - */ - public function deleteConfiguration ($id) { - $part = PartManager::getInstance()->getConfiguration($id); - - PartKeepr::getEM()->remove($part); - PartKeepr::getEM()->flush(); - } - - /** - * Get configuration by its id. - * @param unknown $id - * @return unknown - */ - public function getConfiguration ($id) { - $part = PartKeepr::getEM()->find(getEntityName(), $id); - - return $part; - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationService.php b/src/backend/PartKeepr/Printing/PrintingJobConfiguration/PrintingJobConfigurationService.php @@ -1,87 +0,0 @@ -<?php -namespace PartKeepr\Printing\PrintingJobConfiguration; - -use PartKeepr\PartKeepr, - PartKeepr\Manager\ManagerFilter, - PartKeepr\Printing\PrintingJobConfiguration\PrintingJobConfiguration, - PartKeepr\Printing\PrintingJobConfiguration\PrintingJobConfigurationManager, - PartKeepr\Service\RestfulService, - PartKeepr\Service\FilterExtractor, - PartKeepr\Service\Service; - -/** - * This is our restful service to work with the printing job configurations. - */ -class PrintingJobConfigurationService extends Service implements RestfulService { - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::get() - */ - public function get () { - if ($this->hasParameter("id")) { - return array("data" => PrintingJobConfigurationManager::getInstance()->getEntity($this->getParameter("id"))->serialize()); - } else { - $filter = new ManagerFilter($this); - $filter->setFilterCallback(array($this, "filterCallback")); - - return PrintingJobConfigurationManager::getInstance()->getList($filter); - } - } - - /** - * Advanced filtering for the list - * @param QueryBuilder The $queryBuilder - */ - public function filterCallback ($queryBuilder) { - $filter = new FilterExtractor($this); - - if ($filter->has("objectType") && $filter->get("objectType") != "") { - $queryBuilder->andWhere("q.objectType = :objtype"); - $queryBuilder->setParameter("objtype", $filter->get("objectType") ); - } - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::create() - */ - public function create () { - $this->requireParameter("name"); - - $obj = new PrintingJobConfiguration(); - $obj->deserialize($this->getParameters()); - - PartKeepr::getEM()->persist($obj); - PartKeepr::getEM()->flush(); - - return array("data" => $obj->serialize()); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::update() - */ - public function update () { - $this->requireParameter("id"); - $this->requireParameter("name"); - $obj = PrintingJobConfigurationManager::getInstance()->getEntity($this->getParameter("id")); - $obj->deserialize($this->getParameters()); - - PartKeepr::getEM()->flush(); - - return array("data" => $obj->serialize()); - - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Service\RestfulService::destroy() - */ - public function destroy () { - $this->requireParameter("id"); - - PrintingJobConfigurationManager::getInstance()->deleteEntity($this->getParameter("id")); - - return array("data" => null); - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/PrintingService.php b/src/backend/PartKeepr/Printing/PrintingService.php @@ -1,159 +0,0 @@ -<?php -namespace PartKeepr\Printing; - -use PartKeepr\AuthBundle\Entity\User\UserManager; -use PartKeepr\PartKeepr; -use PartKeepr\Printing\Exceptions\RendererNotFoundException; -use PartKeepr\Printing\PDFLabelRenderer; -use PartKeepr\Printing\PrintingJob\PrintingJob; -use PartKeepr\Printing\PrintingJobConfiguration\PrintingJobConfigurationManager; -use PartKeepr\Service\Service; -use PartKeepr\UploadedFileBundle\Entity\TempUploadedFile; - -/** - * This service is the entry point for our printing/exporting - * service. - */ -class PrintingService extends Service { - /** - * This array contains all object types which can be used to - * for printing. Only these object types will be accepted by the - * generatePrintout method to be able to restrict access to the - * database. - * The value is used to display the selection to the user. - */ - private $availableObjectTypes = array( - 'PartKeepr\StorageLocation\StorageLocation' => 'StorageLocation', - 'PartKeepr\Part\Part' => 'Part' - ); - - /** - * Prints the selected storage locations to a dedicated file - * and returns the url to this file. - */ - public function startExport () { - $this->requireParameter("ids"); - $this->requireParameter("configuration"); - $this->requireParameter("objectType"); - - $ids = explode(',',$this->getParameter("ids")); - $configurationId = $this->getParameter("configuration"); - $objectType = $this->getParameter("objectType"); - - $printerUser = null; - if ($this->hasParameter("target") && $this->getParameter("target") != "") { - $printerUser = UserManager::getInstance()->getUser($this->getParameter("target")); - } - - // check object type for valid object types for security reasons. - // See Select query below and be aware of SQL injection! - if ( !array_key_exists($objectType, $this->availableObjectTypes) ){ - throw new RendererNotFoundException("Object type is forbidden!", $objectType, array_keys($this->availableObjectTypes)); - } - - $configuration = PrintingJobConfigurationManager::getInstance()->getEntity( $configurationId ); - - $query = PartKeepr::getEM()->createQuery("SELECT s FROM $objectType s WHERE s.id IN (?1)"); - $query->setParameter(1,$ids); - $dataToRender = $query->getResult(); - - $renderingObjects = array(); - if ($configuration->getPageLayout() !== null ){ - $renderingObjects[] = $configuration->getPageLayout(); - } - - $renderer = RendererFactoryRegistry::getInstance()->getRendererFactory( $configuration->getExportRenderer()) - ->createInstance( $renderingObjects, $configuration->getRendererConfiguration() ); - - $renderer->passRenderingData($dataToRender); - - $tempFile = tempnam("/tmp", "PWC"); - $renderer->storeResult( $tempFile ); - - $tmpFile = new TempUploadedFile(); - $tmpFile->replace($tempFile); - $tmpFile->setOriginalFilename("generatedFile.".$renderer->getSuggestedExtension()); - PartKeepr::getEM()->persist($tmpFile); - PartKeepr::getEM()->flush(); - - //Create a job if we have a valid printer target - if ($printerUser !== null){ - $job = new PrintingJob(); - $job->setData($tmpFile); - $job->setTarget($printerUser); - PartKeepr::getEM()->persist($job); - PartKeepr::getEM()->flush(); - } - - return array("fileid" => $tmpFile->getId() ); - } - - /** - * This service method will return all available renderers for - * the given data objecttype to render. - */ - public function getAvailableRenderer() { - $objectType = $this->getParameter("objectType", null); - - // Fail early for this type of request! - if ( $objectType!==null && !array_key_exists($objectType, $this->availableObjectTypes) ){ - throw new RendererNotFoundException("Object type is forbidden!", $objectType, array_keys($this->availableObjectTypes) ); - } - - $data = array(); - $renderers = $objectType === null - ? RendererFactoryRegistry::getInstance()->getRendererFactory( null ) - : RendererFactoryRegistry::getInstance()->getRendererFactoryForRenderData( $objectType ); - - foreach ( $renderers as $renderer ){ - $data[] = array("id" => $renderer->getCreatedClassname(), - "name" => $renderer->getName() ); - } - - return array("data" => $data ); - } - - /** - * Retrieve the available types which can be used with the given renderer. - * If no renderer parameter is passed, we will return all types which are supported in - * general. - */ - public function getAvailableTypes() { - $rendererName = $this->getParameter("renderer", ""); - $data = array(); - - if ($rendererName==""){ - foreach ($this->availableObjectTypes as $type => $userType){ - $data[] = array("id" => $type - ,"name" => $userType ); - } - }else{ - $factory = RendererFactoryRegistry::getInstance()->getRendererFactory($rendererName); - $supportedTypes = $factory->getSupportedClassesForRendering(); - - //var_dump($supportedTypes); - - foreach ($supportedTypes as $type ){ - if ( array_key_exists( $type, $this->availableObjectTypes ) ){ - $data[] = array("id" => $type - ,"name" => $this->availableObjectTypes[$type] ); - } - } - } - - return array("data" => $data ); - } - - /** - * Retrieve the needed parameters for the renderer class. - */ - public function getNeededParameters(){ - $this->requireParameter("renderer"); - $rendererName = $this->getParameter("renderer", ""); - $data = array(); - - $factory = RendererFactoryRegistry::getInstance()->getRendererFactory($rendererName); - return array("data" => $factory->getParameterObjectTypes() ); - } - -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/RendererFactoryIfc.php b/src/backend/PartKeepr/Printing/RendererFactoryIfc.php @@ -1,47 +0,0 @@ -<?php - -namespace PartKeepr\Printing; - -/** - * This interface can be used to support different - * sets of renderer. One set of renderer is often used - * to identify a render method like te output format or a - * specific layout of the label. - */ -interface RendererFactoryIfc{ - /** - * This method will create a new concrete instance of the renderer ready to - * use. The returned renderer will always support the RenderingIfc which - * can be used to pass the data to the renderer. - * - * @param array $objects An Array of object instances. Must contain at least all - * objects which are requested by getParameterObjectTypes() - * @param string $configuration - * @return RenderingIfc New renderer to use for rendering. - */ - public function createInstance(array $objects, $configuration); - - /** - * Returns a name for the renderer which is readable to humans. - */ - public function getName(); - - /** - * Returns the class names of the created instances. - */ - public function getCreatedClassname(); - - /** - * Returns the supported classes which can be passed to the renderer - * via passRenderingdata($data). - */ - public function getSupportedClassesForRendering(); - - /** - * Returns the object types, which are required for operation. They - * must be passed to the $configuration parameter as an array. - * - * @return An array holding the names of the type instances needed. - */ - public function getParameterObjectTypes(); -} diff --git a/src/backend/PartKeepr/Printing/RendererFactoryRegistry.php b/src/backend/PartKeepr/Printing/RendererFactoryRegistry.php @@ -1,108 +0,0 @@ -<?php - -namespace PartKeepr\Printing; - -use PartKeepr\Util\Singleton, - PartKeepr\Printing\RendererFactoryIfc, - PartKeepr\Printing\Exceptions\RendererNotFoundException; - -/** - * This registry is used to collect all possible RendererFactories - * and provide an interface to fetch them as needed. - */ -class RendererFactoryRegistry extends Singleton { - /** - * Our list of known factories. - * - * @var array of RendererFactoryIfc instances. - */ - var $factories = array(); - - /** - * Indicates wheather the renderer finding has been exectued so far. - * @var unknown - */ - var $findRendererAlreadyRun = false; - - /** - * Returns a renderer factory by its class name. - * @param string className The name of the class to fetch the factory for. - */ - public function getRendererFactory( $classNameWithNamespace ){ - $this->findRenderer(); - - if ($classNameWithNamespace===null){ - return $this->factories; - } - - if (!array_key_exists($classNameWithNamespace, $this->factories) ){ - throw new RendererNotFoundException("No renderer found in registry.",$classNameWithNamespace, array_keys($this->factories)); - } - - return $this->factories[ $classNameWithNamespace ]; - } - - /** - * Retruns all renderer which are suitable for rendering the fiven data. - * - * @param string $renderDataClassName - */ - public function getRendererFactoryForRenderData( $renderDataClassName ){ - $this->findRenderer(); - - $rval = array(); - foreach ($this->factories as $factory) { - $supported = $factory->getSupportedClassesForRendering(); - if ( array_search( $renderDataClassName, $supported ) !== false ){ - array_push($rval, $factory); - } - } - return $rval; - } - - /** - * Registers a new factory to the tregistry. - * - * @param RendererFactoryIfc $factory The factory to register. - */ - public function registerFactory( RendererFactoryIfc $factory ){ - $this->factories[ $factory->getCreatedClassname() ] = $factory; - } - - /** - * This method searches for the renderer in den Renderer directory and - * loads them. The class itself ensures to run this method once before - * the data from this run is needed. - */ - public function findRenderer(){ - if (!$this->findRendererAlreadyRun){ - foreach (glob(dirname(__FILE__).DIRECTORY_SEPARATOR."Renderer".DIRECTORY_SEPARATOR."*Renderer") as $filename) { - $filename = $filename . DIRECTORY_SEPARATOR . basename($filename) . ".php"; - if (is_file($filename)) { - $className = basename($filename,'.php'); - $classNameWithNamespace = 'PartKeepr\\Printing\\Renderer\\'.$className.'\\'.$className; - $exists = class_exists($classNameWithNamespace); - if ( $exists ){ - try { - $onRegister = new \ReflectionMethod($classNameWithNamespace,'onRegister'); - if ($onRegister->isStatic()){ - // Enough sanity checks, if now something goes wrong, we will fail. - $onRegister->invoke(null,$this); - }else{ - trigger_error("Method onRegister in class $classNameWithNamespace is not static, ignoring class.",E_USER_WARNING ); - } - } catch( \ReflectionException $e) - { - trigger_error("Method onRegister in class $classNameWithNamespace gave an error: ".$e->getMessage().". Ignoring class.",E_USER_WARNING ); - } - }else{ - // Sanely ignore this case, because this may arise often if a needed library is not present. - // trigger_error("File $filename does not contain a class with $classNameWithNamespace.",E_USER_WARNING ); - } - } - } - - $this->findRendererAlreadyRun = true; - } - } -} diff --git a/src/backend/PartKeepr/Printing/RendererIfc.php b/src/backend/PartKeepr/Printing/RendererIfc.php @@ -1,33 +0,0 @@ -<?php -namespace PartKeepr\Printing; - -/** - * The rendering interface is used to pass data to a renderer and - * retrieve the rendered results afterwards. How the data is rendered - * and which data can be processed is implementation specific. - * - * Add a static method onRegister( \PartKeepr\Printing\RendererFactoryRegistry - * $registry ) to your class which will be called to integrate your plugin. - */ -interface RendererIfc{ - /** - * Passes the data which should be rendered. The supported - * data differs from renderer to renderer and is documented - * in the concrete implementations. - * - * @param unknown $data Data to pass to the renderer. - */ - public function passRenderingData( $data ); - - /** - * Returns the suggestion of the file extension to use. - */ - public function getSuggestedExtension(); - - /** - * Store the created result to the given filename. Filename - * can also be treated as a directory if needed. - * @param filename Filename to store the final file. - */ - public function storeResult( $filename ); -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/SimpleRendererFactory.php b/src/backend/PartKeepr/Printing/SimpleRendererFactory.php @@ -1,107 +0,0 @@ -<?php - -namespace PartKeepr\Printing; - -use PartKeepr\Printing\PageBasicLayout\PageBasicLayout; - -/** - * This factory is used to select a concrete renderer for - * rendering the content later. - * - * One renderer can support a specific layout of the later - * printed labels or the sheet. The factory itself supports - * extending it by adding a plugable extension interface. - * - * The constructor of the given object must match the following signature: - * __construct( PrintingPageBasicLayout $layout, array $configuration ) - */ -class SimpleRendererFactory implements RendererFactoryIfc{ - /** - * This is the display name for the user of the underlaying renderer. - * - * @var string - */ - private $name; - - /** - * This is the class name with full namespace path of the class created from - * this factory. This value will be used to have an unique reference name - * to find a class. - * - * @var string - */ - private $className; - - /** - * This array holds all names for supported data classes. These data classes - * can be handled by the renderer via its passRenderingData method. - * - * @var array of strings - */ - private $supportedClasses; - - /** - * The array of configuration parameters the renderer needs to operate. - * This array holds strings off class names with full namespace. They must be - * passed to the createInstance via the $configuration parameter. - * - * @var array of string - */ - private $neededParameterObjectTypes; - - /** - * Constructas a new simple factory for the given class. - * - * @param string $name - * @param string $className - * @param array $supportedClasses - * @param array $neededParameterObjectTypes - */ - public function __construct( $name, $className, array $supportedClasses, array $neededParameterObjectTypes){ - $this->name = $name; - $this->className = $className; - $this->supportedClasses = $supportedClasses; - $this->neededParameterObjectTypes = $neededParameterObjectTypes; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererFactoryIfc::createInstance() - */ - public function createInstance(array $objects, $configuration){ - return new $this->className($objects, $configuration); - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererFactoryIfc::getName() - */ - public function getName(){ - return $this->name; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererFactoryIfc::getCreatedClassname() - */ - public function getCreatedClassname(){ - return $this->className; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererFactoryIfc::getSupportedClassesForRendering() - */ - public function getSupportedClassesForRendering(){ - return $this->supportedClasses; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererFactoryIfc::getParameterObjectTypes() - */ - public function getParameterObjectTypes(){ - return $this->neededParameterObjectTypes; - } -} - diff --git a/src/backend/PartKeepr/Printing/Utils/DecodeConfiguration.php b/src/backend/PartKeepr/Printing/Utils/DecodeConfiguration.php @@ -1,32 +0,0 @@ -<?php -namespace PartKeepr\Printing\Utils; - -use PartKeepr\Printing\Exceptions\InvalidArgumentException; -use PartKeepr\PartKeepr; - -/** - * Helper class which enables us to decode a configuration which was passed as JSON - * string. The class will also do error handling of data inside the JSON. - */ -class DecodeConfiguration{ - /** - * Method decodes the incoming string and returns the JSON decoded array if - * everything was fine. If a syntax error was detected, it throws an exception. - * - * @param string $string - * @throws InvalidArgumentException - */ - public static function decode( $string ){ - $jsonDecoded = json_decode(trim($string), true); - if ($jsonDecoded===null){ - if (strlen($string) == 0 ){ - $jsonDecoded = array(); - } - else{ - throw new InvalidArgumentException( PartKeepr::i18n('Extended rendering configuration contains an error!')); - } - } - - return $jsonDecoded; - } -}- \ No newline at end of file diff --git a/src/backend/PartKeepr/Printing/Utils/PercentOrNumericHelper.php b/src/backend/PartKeepr/Printing/Utils/PercentOrNumericHelper.php @@ -1,101 +0,0 @@ -<?php -namespace PartKeepr\Printing\Utils; - -/** - * This is a helper class to extract a number or a percentage - * from an argument. - * The following string represents a percentage: 100% - * And just the raw number will be dealt as absolute number: 100 - * - * Additionally in percentage mode an additional absolute offset can - * be given: 50% - 4 => - */ -class PercentOrNumericHelper{ - private $percentageValue; - - private $absoluteValue; - - /** - * Constructs new class und use the parameter as argument. - * @param $toAnalyze This is our absolute numberic or percentage value - */ - public function __construct($toAnalyze){ - if (is_numeric($toAnalyze)){ - $this->percentageValue = 0; - $this->absoluteValue = $toAnalyze; - } - else{ - $this->isAbsolute = false; - if (preg_match('/^\s*([+-]*[0-9]+)\s*%\s*(([+-])\s*([0-9]+))*\s*$/', $toAnalyze, $matches ) === 1 ){ - $this->percentageValue = $matches[1] / 100; - if (count($matches)>2){ - $this->absoluteValue = $matches[2]; - }else{ - $this->absoluteValue = 0; - } - } - else { - // Error in string, throw user error??? - $this->percentageValue = 0; - $this->absoluteValue = 0; - } - } - } - - /** - * Converts this value to be between minValue and maxValue. - * If the analyzed value is: - * - percentage: The percentage represents the position between min and max - * - absolute: The absolute value will be used as is if inside bounds and will - * be min if smaller or max if greater - */ - public function getValue( $minValue, $maxValue ){ - if ($minValue>$maxValue ){ - list($minValue,$maxValue) = array($maxValue,$minValue); - } - - $value = $this->percentageValue * ($maxValue - $minValue) + $minValue + $this->absoluteValue; - - $value = min( $maxValue, $value); - return max( $minValue, $value); - } - - /** - * This method works like getValue, but will wrap around if the value is out of bound. - */ - public function getValueWrap( $minValue, $maxValue ){ - if ($minValue>$maxValue ){ - list($minValue,$maxValue) = array($maxValue,$minValue); - } - $distance = ($maxValue - $minValue); - $calculatedDistance = $this->percentageValue * $distance + $this->absoluteValue; - - $distanceTimes = floor( $calculatedDistance / $distance ); - $calculatedDistance -= $distanceTimes * $distance; - - return $minValue + $calculatedDistance; - } - - /** - * Returns the value without any bounding. Returns either the absolute value - * or $range * $percentage - */ - public function getValueUnbound( $range ){ - return $range * $this->percentageValue + $this->absoluteValue; - } - - /** - * Returns the percentage part of the value. - */ - public function getPercentageValue(){ - return $this->percentageValue; - } - - /** - * Returns the absolute part of the value. - */ - public function getAbsoluteValue(){ - return $this->absoluteValue; - } - -} diff --git a/src/backend/PartKeepr/Printing/Utils/Placeholder.php b/src/backend/PartKeepr/Printing/Utils/Placeholder.php @@ -1,92 +0,0 @@ -<?php -namespace PartKeepr\Printing\Utils; - -use - PartKeepr\Part\Part, - PartKeepr\StorageLocation\StorageLocation; - -/** - * This class is used to provide the ability to replace text inside a string. - * These texts can have various sources. Previous to the use the placeholder class - * needs to be initialized with the set to use. - */ -class Placeholder{ - /** - * This is our array with the replacements for search and replace. - */ - private $replacements = array(); - - /** - * This is the passed begin token for detection at the beginning. - * @var string - */ - private $beginToken; - - /** - * This is the passed end token for detecting the end of the replacement. - * @var string - */ - private $endToken; - - /** - * Constructs a new placeholder class and use the object to fill - * the placeholder with. - * - * @param unknown $object - */ - public function __construct ( $object, $begin = "<<", $end = ">>" ) { - $replace = array(); - if ( $object instanceof Part ){ - $replace = array( - 'id' => $object->getId(), - 'barcodeId' => $object->getId() * 10 + 1, - 'name' => $object->getName(), - 'internalNumber' => $object->getInternalPartNumber(), - 'description' => $object->getDescription(), - 'categoryFull' => $object->getCategory()->getCategoryPath(), - 'categoryLast' => $object->getCategory()->getName(), - 'footprintName' => $object->getFootprint() === null ? '': $object->getFootprint()->getName(), - 'storageLocationName' => $object->getStorageLocation() === null ? '': $object->getStorageLocation()->getName() - ); - }else if ( $object instanceof StorageLocation ){ - $replace = array( - 'id' => $object->getId(), - 'barcodeId' => $object->getId() * 10 + 2, - 'name' => $object->getName() - ); - } - - $this->beginToken = $begin; - $this->endToken = $end; - $this->replacements = $replace; - } - - /** - * Applies the placeholders and retruns the replaced string. - * - * @param string $text Text to replace the placeholders in. - */ - public function apply( $text ){ - $beginEscaped = preg_quote( $this->beginToken, '/'); - $endEscaped = preg_quote( $this->endToken, '/'); - - $replacements = $this->replacements; - $callback = function( $matches ) use ($replacements) { - if (!array_key_exists($matches[1],$replacements)) - return "Error: Unknown field!"; - $filedContent = $replacements[$matches[1]]; - if (strlen($matches[2])==0){ - return $filedContent; - }else{ - return sprintf($matches[3],$filedContent); - } - }; - - $regex = '/'.$beginEscaped."([a-zA-Z]+)(|,(.*?))".$endEscaped.'/'; - $text = preg_replace_callback( $regex - , $callback, $text); - - return $text; - } - -}- \ No newline at end of file diff --git a/src/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/PDFDefaultRenderer.php b/src/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/PDFDefaultRenderer.php @@ -1,233 +0,0 @@ -<?php -namespace PartKeepr\Printing\Renderer\PDFDefaultRenderer; - -use PartKeepr\Part\Part, - PartKeepr\Printing\Exceptions\RendererNotFoundException, - PartKeepr\Printing\PageBasicLayout\PageBasicLayout, - PartKeepr\Printing\RendererFactoryRegistry, - PartKeepr\Printing\Renderer\PDFDefaultRenderer\TCPDFAbstractRenderer, - PartKeepr\Printing\SimpleRendererFactory, - PartKeepr\Printing\Utils\PercentOrNumericHelper, - PartKeepr\Printing\Utils\Placeholder, - PartKeepr\Printing\Utils\DecodeConfiguration, - PartKeepr\StorageLocation\StorageLocation - ; - -/** - * This class implements a way to render different datasets to - * a labeling layout. - */ -class PDFDefaultRenderer extends TCPDFAbstractRenderer{ - /** - * Our default configuration for this label renderer. - * @var array - */ - private $defaultConfiguration = array( - 'barcodeEnable' => false, - 'barcodeType' => 'QRCODE,L', - 'textBarcode' => "!!barcodeId,%06d!!", - 'barcodeWidth' => "12", - 'barcodeHeight' => "12", - 'barcodeXPos' => "-7", - 'barcodeYPos' => "7", - 'barcodeWithText' => false, - 'barcode2D' => true, - 'fontFamily' => 'times', - 'fontStyle' => '', - 'fontSize' => 12, - 'text' => '<span style="font-size: 11pt;"><b>!!name!!</b></span><br><span style="font-size: 8pt;">!!description!!</span>', - 'textXOffset' => 0, - 'textYOffset' => 0 - ); - - /** - * @param array $objects needs at least an instance of the PageBasicLayout. - * @param unknown $cfgString The configuration string. - */ - public function __construct (array $objects, $cfgString ) { - $configuration = DecodeConfiguration::decode($cfgString); - - // Apply the personal default configuration here. - // The base will apply the base default parameters for you. - $configuration = array_merge( $this->defaultConfiguration, $configuration ); - parent::__construct( $objects, $configuration); - } - - public function passRenderingData( $data ){ - // Here we got our data passed. We have to decide how we want - // to render the data, so we dispatch it to our internal rendering - // methods to make the code more clear. - if ( is_array( $data ) ){ - if (count($data)>0){ - $elem = reset($data); - if ($elem instanceof StorageLocation || $elem instanceof Part ){ - $this->renderObjects($data); - }else{ - throw new RendererNotFoundException("Unable to handle object type with renderer PDFLabelRenderer.", - get_class($elem),array("StorageLocation","Part")); - } - } - } - else{ - // If the selected object is not an array, we make an array first - // to have only one case to handle. - passRenderingData( array( $ata ) ); - } - } - - /** - * This method renders an array of Parts to our sheet. - * @param array $parts - */ - private function renderObjects( array $objects ){ - foreach ($objects as $obj){ - $this->renderCell( $obj ); - } - } - - /** - * This method just renders the next single cell with a part - * as content. - */ - private function renderCell( $object ){ - // Move the pointer to the next cell and initialize PDF class - // correctly. Also draws the grid if necessary. - $this->initNextCell(); - - $padding = 3; - - $dataReplacement = new Placeholder( $object, "!!", "!!" ); - - $text = $dataReplacement->apply($this->configuration['text']); - $barcodeId = $dataReplacement->apply($this->configuration['textBarcode'] ); - - $this->pdf->SetCellPadding($padding); - $this->pdf->SetFont( $this->configuration['fontFamily'], - $this->configuration['fontStyle'], - $this->configuration['fontSize']); - $this->pdf->SetXY( $this->xCellPos,$this->yCellPos ); - - if ($this->configuration['barcodeEnable']){ - $widthParameter = new PercentOrNumericHelper($this->configuration['barcodeWidth']); - $heightParameter = new PercentOrNumericHelper($this->configuration['barcodeHeight']); - $xPosParameter = new PercentOrNumericHelper($this->configuration['barcodeXPos']); - $yPosParameter = new PercentOrNumericHelper($this->configuration['barcodeYPos']); - - $xPos = $xPosParameter->getValueWrap(0, $this->layout->getCellWidthInMM() ); - $yPos = $yPosParameter->getValueWrap(0, $this->layout->getCellHeightInMM() ); - $width = $widthParameter->getValue(0,$this->layout->getCellWidthInMM()); - $height = $heightParameter->getValue(0,$this->layout->getCellHeightInMM()); - - $regions = array(); - - // Shitty workaround for a Bug in TCPDF the ower is not interested in fixing it! - $this->pdf->resetInternalMargins(); - - if ($this->configuration['barcode2D']){ - $this->pdf->write2DBarcode($barcodeId, $this->configuration['barcodeType'], - $this->xCellPos + $xPos - $width / 2 , - $this->yCellPos + $yPos - $height / 2, - $width, - $height - ); - } else { - $style = array('text'=> $this->configuration['barcodeWithText'] ); - $this->pdf->write1DBarcode($barcodeId, $this->configuration['barcodeType'], - $this->xCellPos + $xPos - $width / 2 , - $this->yCellPos + $yPos - $height / 2, - $width, - $height, - "", - $style - ); - } - - // This region will add a "do not write text here" over our barcode This is a kind - // of hack to make text fluently moving around :) - $textMarginX = 7; - $textMarginY = 7; - - $left = $xPos < $this->layout->getCellWidthInMM() / 2; - $top = $yPos < $this->layout->getCellHeightInMM() / 2; - - // $this->pdf->writeHTML("LEFT: $left TOP: $top XPOS: $xPos YPOS: $yPos WIDTH: ".$this->layout->getCellWidthInMM()." HEIGHT: ".$this->layout->getCellHeightInMM(), true, false, true, false, ''); - if( $left ) - { - if( $top ){ - $regions[] = array('page' => '' - , 'xt' => $xPos + $this->xCellPos + $textMarginX - , 'yt' => 0 - , 'xb' => $xPos + $this->xCellPos + $textMarginX - , 'yb' => $yPos + $this->yCellPos + $textMarginY, 'side' => 'L'); - }else - { - $regions[] = array('page' => '' - , 'xt' => $xPos + $this->xCellPos + $textMarginX - , 'yt' => $yPos + $this->yCellPos - $textMarginY - , 'xb' => $xPos + $this->xCellPos + $textMarginX - , 'yb' => $this->yCellPos + $this->layout->getCellHeightInMM() - , 'side' => 'L'); - } - }else - { - if( $top ){ - $regions[] = array('page' => '' - , 'xt' => $xPos + $this->xCellPos - $textMarginX - , 'yt' => 0 - , 'xb' => $xPos + $this->xCellPos - $textMarginX - , 'yb' => $yPos + $this->yCellPos + $textMarginY, 'side' => 'R'); - }else - { - $regions[] = array('page' => '' - , 'xt' => $xPos + $this->xCellPos - $width / 2 - $textMarginX - , 'yt' => $yPos + $this->yCellPos - $height/ 2 - $textMarginY - , 'xb' => $xPos + $this->xCellPos - $width / 2 - $textMarginX - , 'yb' => $this->yCellPos + $this->layout->getCellHeightInMM() - , 'side' => 'R'); - } - } - $this->pdf->setPageRegions($regions); - } - - // Start clipping. Every thing with StartTransform and StopTransform - // will be clipped to the Rect. This is a cool feature if one field is - // too long, it will not destroy the rest of your page and it is partial - // usable. - $this->pdf->StartTransform(); - // Draw clipping rectangle to match html cell. - $this->pdf->Rect($this->xCellPos, $this->yCellPos, $this->layout->getCellWidthInMM(), - $this->layout->getCellHeightInMM(), 'CNZ'); - - $xPosTextOffsetParameter = new PercentOrNumericHelper($this->configuration['textXOffset']); - $yPosTextOffsetParameter = new PercentOrNumericHelper($this->configuration['textYOffset']); - - $this->pdf->WriteHTMLCell( $this->layout->getCellWidthInMM(), - $this->layout->getCellHeightInMM(), - $this->xCellPos + $xPosTextOffsetParameter->getValueUnbound( $this->layout->getCellWidthInMM() ), - $this->yCellPos + $yPosTextOffsetParameter->getValueUnbound( $this->layout->getCellWidthInMM() ), - $text); - - $this->pdf->StopTransform(); - - $this->pdf->setPageRegions(); - } - - /** - * Registers this renderer class to the registry. - * - * @param RendererFactoryRegistry $registry - */ - public static function onRegister( RendererFactoryRegistry $registry ){ - // We have to register this class to the registry. - // Only if the class is registered, it can be found by the - // registry and you will see it in the application. - $registry->registerFactory( - new SimpleRendererFactory("Default PDF renderer", - "PartKeepr\Printing\Renderer\PDFDefaultRenderer\PDFDefaultRenderer", - array("PartKeepr\StorageLocation\StorageLocation", - "PartKeepr\Part\Part"), - array("PartKeepr\Printing\PageBasicLayout\PageBasicLayout") - ) - ); - } -} diff --git a/src/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/TCPDFAbstractRenderer.php b/src/backend/Plugins/PrintingRenderer/PDFDefaultRenderer/TCPDFAbstractRenderer.php @@ -1,205 +0,0 @@ -<?php -namespace PartKeepr\Printing\Renderer\PDFDefaultRenderer; - -use PartKeepr\Printing\RendererIfc, - PartKeepr\Printing\RendererFactoryRegistry, - PartKeepr\Printing\RendererNotFoundException, - PartKeepr\Printing\SimpleRendererFactory, - PartKeepr\Printing\PageBasicLayout\PageBasicLayout, - PartKeepr\StorageLocation\StorageLocation - ; - -require_once('tcpdf/tcpdf.php'); - -/** - * This wrapper class can be used to remove some bugs from the - * TCPDF. https://sourceforge.net/p/tcpdf/bugs/773/ - * @author sven - * - */ -class TCPDFWrapper extends \TCPDF{ - public function __construct($orientation, $unit, $format){ - parent::__construct($orientation, $unit, $format); - } - - public function resetInternalMargins(){ - $this->crMargin = $this->rMargin = $this->original_rMargin; - $this->clMargin = $this->lMargin = $this->original_lMargin; - } -} - -/** - * This class is a abstract renderer to help somebody by creating its - * own plugins. Use the PDFDefaultRenderer as an example. - */ -abstract class TCPDFAbstractRenderer implements RendererIfc{ - /** - * This contains our layout for the page to be rendered. - */ - protected $layout = null; - - /** - * Our internal used pdf generator. - */ - protected $pdf; - - /** - * This is the count of the cells we have actually rendered. You can name - * it a pointer to the next cell, which should be rendered. We render all - * columns first and then increment the row. - */ - protected $cellsRendered; - - /** - * This is the position of the actual cell we want to process. - * Top left point. - */ - protected $xCellPos = 0; - - /** - * This is the position of the actual cell we want to process. - * Top left point. - */ - protected $yCellPos = 0; - - /** - * This is an array with configuration things. - * @var array - */ - protected $configuration; - - /** - * This boolean can be set to true to not trigger an error on startup. - * We implement it this way, to ensure the implementer of the plugin has - * thought of this potential security risk. - * - * @var unknown - */ - protected $doNotErrorIfTCPDFSetsCalls = false; - - /** - * Our default configuration for this label renderer. - * @var array - */ - protected $basedefaultConfiguration = array( - 'borderGrid' => true, - 'startingCell' => 0 - ); - - public function __construct ( array $objects, array $configuration ) { - foreach( $objects as $obj ){ - if ($obj instanceof \PartKeepr\Printing\PageBasicLayout\PageBasicLayout){ - $this->layout = $obj; - } - } - - if ($this->layout === null){ - throw new \PartKeepr\Printing\Exceptions\InvalidArgumentException("Required object not passed!"); - } - - $this->configuration = array_merge( $this->basedefaultConfiguration, $configuration ); - - $this->cellsRendered = $this->configuration['startingCell']; - - if (K_TCPDF_CALLS_IN_HTML && !$doNotErrorIfTCPDFSetsCalls){ - trigger_error("TCPDF has set K_TCPDF_CALLS_IN_HTML to true, which is a security issue with this class since the user can modify the html text!",E_USER_ERROR); - } - - $this->pdf = new TCPDFWrapper( $this->layout->getPaperPortrait() ? 'P': 'L' - , 'mm', $this->layout->getPaperSize() ); - - // set document information - $this->pdf->SetCreator(PDF_CREATOR); - $this->pdf->SetAuthor('PartDB'); - $this->pdf->SetTitle('PartDB Labeling Document'); - $this->pdf->SetSubject('This is a priontout of for labeling or indexing'); - $this->pdf->SetKeywords('PartDB'); - - // remove default header/footer - $this->pdf->setPrintHeader(false); - $this->pdf->setPrintFooter(false); - - // set default monospaced font - $this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); - - //set margins - $this->pdf->SetMargins(0, 0, 0); - - //set auto page breaks - $this->pdf->SetAutoPageBreak(FALSE, 0); - - //set image scale factor - $this->pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); - - //set some language-dependent strings - //$this->pdf->setLanguageArray($l); - - // --------------------------------------------------------- - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererIfc::getSuggestedExtension() - */ - public function getSuggestedExtension(){ - return "pdf"; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererIfc::storeResult() - */ - public function storeResult( $outFile ){ - $this->pdf->Output($outFile, 'F'); - } - - /** - * - * @param unknown $filename - */ - public function outputResult($filename){ - $this->pdf->Output($filename, 'I'); - } - - /** - * Renders a border grid which is based on the layout. - */ - protected function renderBorderGrid(){ - $colYStart = $this->layout->getTopLeftYInMM(); - $colYEnd = $this->layout->getRowCount() * $this->layout->getCellHeightInMM() + $this->layout->getTopLeftYInMM(); - - $rowXStart = $this->layout->getTopLeftXInMM(); - $rowXEnd = $this->layout->getColumnCount() * $this->layout->getCellWidthInMM() + $this->layout->getTopLeftXInMM(); - - for ($r=0; $r <= $this->layout->getRowCount(); $r++){ - $rowYPos = $r * $this->layout->getCellHeightInMM() + $this->layout->getTopLeftYInMM(); - $this->pdf->Line( $rowXStart, $rowYPos, $rowXEnd, $rowYPos ); - } - - for ($c=0; $c <= $this->layout->getColumnCount(); $c++){ - $colXPos = $c * $this->layout->getCellWidthInMM() + $this->layout->getTopLeftXInMM(); - $this->pdf->Line( $colXPos, $colYStart, $colXPos, $colYEnd ); - } - } - - /** - * Opens the cell and sets the class to the correct coordinates. - */ - protected function initNextCell(){ - $page = floor( $this->cellsRendered / ($this->layout->getColumnCount() * $this->layout->getRowCount())); - $cellXCoordinate = $this->cellsRendered % $this->layout->getColumnCount(); - $cellYCoordinate = ( floor($this->cellsRendered / $this->layout->getColumnCount()) ) % $this->layout->getRowCount() ; - - $this->xCellPos = $cellXCoordinate * $this->layout->getCellWidthInMM() + $this->layout->getTopLeftXInMM(); - $this->yCellPos = $cellYCoordinate * $this->layout->getCellHeightInMM() + $this->layout->getTopLeftYInMM(); - - if ($cellXCoordinate == 0 && $cellYCoordinate == 0){ - $this->pdf->AddPage(); - if ($this->configuration['borderGrid']){ - $this->renderBorderGrid(); - } - } - - $this->cellsRendered++; - } -} diff --git a/src/backend/Plugins/PrintingRenderer/ZebraLabelWriterRenderer/ZebraLabelWriterRenderer.php b/src/backend/Plugins/PrintingRenderer/ZebraLabelWriterRenderer/ZebraLabelWriterRenderer.php @@ -1,165 +0,0 @@ -<?php -namespace PartKeepr\Printing\Renderer\ZebraLabelWriterRenderer; - -use PartKeepr\Part\Part, - PartKeepr\Printing\PageBasicLayout\PageBasicLayout, - PartKeepr\Printing\RendererFactoryRegistry, - PartKeepr\Printing\RendererIfc, - PartKeepr\Printing\SimpleRendererFactory, - PartKeepr\Printing\Exceptions\RendererNotFoundException, - PartKeepr\Printing\Utils\DecodeConfiguration, - PartKeepr\Printing\Utils\Placeholder, - PartKeepr\StorageLocation\StorageLocation - ; - -/** - * This class implements a printing renderer which renders the data - * to the ZPL printing language. The idea behind is to create a template using - * the Designer software provided by Zebra, print it to a file and then use this - * file as a template here. - */ -class ZebraLabelWriterRenderer implements RendererIfc{ - /** - * Our default configuration for this label renderer. - * @var array - */ - private $defaultConfiguration = array( - 'template' => -<<<'EOD' -CT~~CD,~CC^~CT~ -^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR3,3~SD8^JUS^LRN^CI0^XZ -^XA -^MMT -^PW320 -^LL0176 -^LS0 -^FT16,44^A0N,34,33^FH\^FD<<name>>^FS -^FT16,76^A0N,23,24^FH\^FD<<description>>^FS -^BY3,3,33^FT49,146^BCN,,Y,N -^FD>;<<barcodeId,%06d>>^FS -^PQ1,0,1,Y^XZ -EOD - ); - - /** - * The rendered data up to now. - */ - protected $out = ""; - - /** - * This is the current active configuration. - * @var unknown - */ - protected $configuration; - - /** - * This is the configuration passed to this class. - * @var unknown - */ - protected $configurationIn; - - /** - * @param array $obj dummy, not needed. - * @param unknown $cfgString The configuration string. - */ - public function __construct (array $obj, $cfgString ) { - $configuration = DecodeConfiguration::decode($cfgString); - $this->configurationIn = $configuration; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererIfc::passRenderingData() - */ - public function passRenderingData( $data ){ - // Here we got our data passed. We have to decide how we want - // to render the data, so we dispatch it to our internal rendering - // methods to make the code more clear. - if ( is_array( $data ) ){ - if (count($data)>0){ - $elem = reset($data); - if ($elem instanceof StorageLocation || $elem instanceof Part){ - $this->renderObjects($data); - } - else{ - throw new RendererNotFoundException("Unable to handle object type with this renderer.", - get_class($elem),array("StorageLocation","Part")); - } - } - } - else{ - // If the selected object is not an array, we make an array first - // to have only one case to handle. - passRenderingData( array( $ata ) ); - } - } - - /** - * This method renders an array of Objects to our labels. - * @param array $objects - */ - private function renderObjects( array $objects ){ - $this->configuration = array_merge( $this->defaultConfiguration, $this->configurationIn ); - - foreach ($objects as $obj){ - $this->renderSingleObject( $obj ); - } - } - - - /** - * Just render a single object to the output. - * - * @param $object - */ - private function renderSingleObject( $object ){ - $dataReplacement = new Placeholder( $object, "<<", ">>"); - $this->out .= $dataReplacement->apply($this->configuration['template']) . "\n"; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererIfc::getSuggestedExtension() - */ - public function getSuggestedExtension(){ - return "zpl"; - } - - /** - * (non-PHPdoc) - * @see \PartKeepr\Printing\RendererIfc::storeResult() - */ - public function storeResult( $outFile ){ - $file = fopen($outFile,'w'); - fwrite( $file, $this->out ); - fclose( $file ); - } - - /** - * - * @param unknown $filename - * @return string - */ - public function outputResult($filename){ - return $this->out; - } - - /** - * Registers this renderer class to the registry. - * - * @param RendererFactoryRegistry $registry - */ - public static function onRegister( RendererFactoryRegistry $registry ){ - // We have to register this class to the registry. - // Only if the class is registered, it can be found by the - // registry and you will see it in the application. - $registry->registerFactory( - new SimpleRendererFactory("Zebra Label Renderer", - "PartKeepr\Printing\Renderer\ZebraLabelWriterRenderer\ZebraLabelWriterRenderer", - array("PartKeepr\Part\Part","PartKeepr\StorageLocation\StorageLocation"), - array() - ) - ); - } -} -