当前位置: 首页>>代码示例>>PHP>>正文


PHP PartKeepr\PartKeepr类代码示例

本文整理汇总了PHP中PartKeepr\PartKeepr的典型用法代码示例。如果您正苦于以下问题:PHP PartKeepr类的具体用法?PHP PartKeepr怎么用?PHP PartKeepr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PartKeepr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
     $classes = PartKeepr::getClassMetaData();
     $tool->updateSchema($classes, true);
     $this->logMessage("Database Schema created/updated");
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:7,代码来源:SchemaSetup.php

示例2: markAllTipsAsUnread

 /**
  * Marks all tips as unread for the current user
  */
 public function markAllTipsAsUnread()
 {
     $dql = "DELETE FROM PartKeepr\\TipOfTheDay\\TipOfTheDayHistory th WHERE th.user = :user";
     $query = PartKeepr::getEM()->createQuery($dql);
     $query->setParameter("user", $this->getUser());
     $query->execute();
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:10,代码来源:TipOfTheDayService.php

示例3: getManufacturerByName

 /**
  * Retrieves a manufacturer by its name.
  * 
  * @param string $name The name of the manufacturer to retrieve
  * @throws Doctrine\ORM\NoResultException If the manufacturer was not found
  */
 public function getManufacturerByName($name)
 {
     $dql = "SELECT m FROM PartKeepr\\Manufacturer\\Manufacturer m WHERE m.name = :name";
     $query = PartKeepr::getEM()->createQuery($dql);
     $query->setParameter("name", $name);
     return $query->getSingleResult();
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:13,代码来源:ManufacturerManager.php

示例4: setupUnits

 /**
  * Sets up the default units
  * @throws \Exception
  */
 public function setupUnits()
 {
     $count = 0;
     $skipped = 0;
     $data = Setup::loadYAML(self::UNIT_DATA_FILE);
     $aUnits = array();
     foreach ($data as $unitName => $unitData) {
         if (UnitManager::getInstance()->unitExists($unitName)) {
             $skipped++;
             continue;
         }
         $unit = new Unit();
         $unit->setName($unitName);
         $unit->setSymbol($unitData["symbol"]);
         if (array_key_exists("prefixes", $unitData)) {
             if (!is_array($unitData["prefixes"])) {
                 throw new \Exception($unitName . " doesn't contain a prefix list, or the prefix list is not an array.");
             }
             foreach ($unitData["prefixes"] as $prefix) {
                 $siPrefix = SiPrefixManager::getInstance()->getSiPrefixBySymbol($prefix);
                 if ($siPrefix === false) {
                     throw new \Exception("Unable to find prefix " . $prefix);
                 }
                 $unit->getPrefixes()->add($siPrefix);
             }
         }
         PartKeepr::getEM()->persist($unit);
         $count++;
     }
     $this->entityManager->flush();
     $this->logMessage(sprintf("Imported %d Units, skipped %d because they already exist", $count, $skipped));
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:36,代码来源:UnitSetup.php

示例5: getNotifiedListeners

 /**
  * Get all entries which are notified by the event.
  */
 public function getNotifiedListeners()
 {
     $session = SessionManager::getCurrentSession();
     $query = PartKeepr::getEM()->createQuery("SELECT l FROM PartKeepr\\EventNotification\\LastNotification l JOIN l.session s JOIN l.event e WHERE s.id = ?1 AND e.lastOccured > l.lastNotify");
     $query->setParameter(1, $session->getId());
     return $query->getResult();
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:10,代码来源:LastNotificationManager.php

示例6: fallbackSearch

 /**
  * A fallback search in case no fulltext search engine is available. This directly queries the database, which is
  * slow. 
  */
 protected function fallbackSearch()
 {
     $qb = PartKeepr::getEM()->createQueryBuilder();
     $qb->select("q.id")->from($this->getEntityName(), "q")->where("1=1");
     $dqlChunks = array();
     foreach ($this->query as $id => $queryString) {
         $partDqlChunks = array();
         foreach ($this->getFields() as $field) {
             $partDqlChunks[] = "LOWER(q." . $field . ") LIKE :filter" . $id;
         }
         $dqlChunks[] = "(" . implode(" OR ", $partDqlChunks) . ")";
         $qb->setParameter("filter" . $id, "%" . str_replace("%", "\\%", strtolower($queryString)) . "%");
     }
     $qb->andWhere(implode(" AND ", $dqlChunks));
     $query = $qb->getQuery();
     $result = $query->getArrayResult();
     if (count($result) > 0) {
         $results = array();
         foreach ($result as $value) {
             $results[] = $value["id"];
         }
         return $results;
     } else {
         return array(0);
     }
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:30,代码来源:FulltextSearch.php

示例7: getManufacturerICLogos

 /**
  * 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();
     $qb->select("st.id, maf.id AS manufacturer_id")->from("PartKeepr\\Manufacturer\\ManufacturerICLogo", "st")->leftJoin('st.manufacturer', "maf");
     if ($filter != "") {
         $manufacturer = Manufacturer::loadById($filter);
         $qb = $qb->where("st.manufacturer = :manufacturer");
         $qb->setParameter("manufacturer", $manufacturer);
     }
     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\\Manufacturer\\ManufacturerICLogo", "st");
     if ($filter != "") {
         $totalQueryBuilder = $totalQueryBuilder->where("st.manufacturer = :manufacturer");
         $totalQueryBuilder->setParameter("manufacturer", $manufacturer);
     }
     $totalQuery = $totalQueryBuilder->getQuery();
     return array("data" => $result, "totalCount" => $totalQuery->getSingleScalarResult());
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:34,代码来源:ManufacturerICLogoManager.php

示例8: getDistributorByName

 /**
  * Retrieves a distributor by its name.
  *
  * @param string $name The name of the distributor to retrieve
  * @throws Doctrine\ORM\NoResultException If the distributor was not found
  */
 public function getDistributorByName($name)
 {
     $dql = "SELECT d FROM PartKeepr\\Distributor\\Distributor d WHERE d.name = :name";
     $query = PartKeepr::getEM()->createQuery($dql);
     $query->setParameter("name", $name);
     return $query->getSingleResult();
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:13,代码来源:DistributorManager.php

示例9: getProjectAttachments

 /**
  * Returns a list of project attachments
  *
  * @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 project id
  */
 public function getProjectAttachments($start = 0, $limit = 10, $sort = "name", $dir = "asc", $filter = "")
 {
     $qb = PartKeepr::getEM()->createQueryBuilder();
     $qb->select("st")->from("PartKeepr\\Project\\ProjectAttachment", "st")->leftJoin('st.project', "fp");
     if ($filter != "") {
         $project = Project::loadById($filter);
         $qb = $qb->where("st.project = :project");
         $qb->setParameter("project", $project);
     }
     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\\Project\\ProjectAttachment", "st");
     if ($filter != "") {
         $totalQueryBuilder = $totalQueryBuilder->where("st.project = :project");
         $totalQueryBuilder->setParameter("project", $project);
     }
     $totalQuery = $totalQueryBuilder->getQuery();
     $aData = array();
     foreach ($result as $item) {
         $aData[] = $item->serialize();
     }
     return array("data" => $aData, "totalCount" => $totalQuery->getSingleScalarResult());
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:38,代码来源:ProjectAttachmentManager.php

示例10: dumpConfig

    /**
     * Returns a configuration file, based on all configurations.
     * 
     * @param none
     * @return string A complete configuration file including namespace and use directives
     */
    public static function dumpConfig()
    {
        $config = <<<EOD
<?php
namespace PartKeepr;
use PartKeepr\\Util\\Configuration;


EOD;
        foreach (Configuration::$options as $option => $value) {
            switch (PartKeepr::getType($value)) {
                case "string":
                    $config .= 'Configuration::setOption("' . $option . '", "' . $value . '");' . "\n";
                    break;
                case "boolean":
                    $config .= 'Configuration::setOption("' . $option . '", ' . ($value === true ? 'true' : 'false') . ');' . "\n";
                    break;
                case "integer":
                case "numeric":
                    $config .= 'Configuration::setOption("' . $option . '", ' . intval($value) . ');' . "\n";
                    break;
                case "float":
                    $config .= 'Configuration::setOption("' . $option . '", ' . floatval($value) . ');' . "\n";
                    break;
                default:
                    break;
            }
        }
        return $config;
    }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:36,代码来源:Configuration.php

示例11: update

 /**
  * (non-PHPdoc)
  * @see PartKeepr\Service.RestfulService::update()
  */
 public function update()
 {
     $this->requireParameter("id");
     $stockEntry = StockEntry::loadById($this->getParameter("id"));
     if (!SessionManager::getCurrentSession()->getUser()->isAdmin() && !(SessionManager::getCurrentSession()->getUser() && $stockEntry->getUser() && SessionManager::getCurrentSession()->getUser()->getId() == $stockEntry->getUser()->getId())) {
         throw new \Exception("Permission denied");
     }
     /* It's not allowed to edit a price for a removal */
     if (!$stockEntry->isRemoval()) {
         $stockEntry->setPrice(abs($this->getParameter("price")));
     }
     /**
      * Only an admin user may correct the in&out stock levels
      */
     if (SessionManager::getCurrentSession()->getUser()->isAdmin()) {
         if ($this->getParameter("direction") == "out") {
             $stockEntry->setStockLevel(-abs($this->getParameter("stockLevel")));
         } else {
             $stockEntry->setStockLevel($this->getParameter("stockLevel"));
         }
     }
     if (SessionManager::getCurrentSession()->getUser()->isAdmin()) {
         try {
             $stockEntry->setUser(User::loadById($this->getParameter("user_id")));
         } catch (\Exception $e) {
             $stockEntry->setUser(null);
         }
     }
     $stockEntry->setComment($this->getParameter("comment"));
     PartKeepr::getEM()->flush();
     return array("data" => $stockEntry->serialize());
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:36,代码来源:StockService.php

示例12: getSampledStatistics

 /**
  * Returns sampled statistics from the database. 
  * 
  * This call takes a start and an end time, and calculates a set of statistics
  * for each interval.
  * 
  *  The sampleSize, which has a default of 50, specifies how many single statistic
  *  points in the given date interval will be returned.
  *  
  *  This function interpolates the statistics if there are not enough statistic samples available.
  */
 public function getSampledStatistics()
 {
     $fooStart = microtime(true);
     $this->requireParameter("startDateTime");
     $this->requireParameter("endDateTime");
     $start = \DateTime::createFromFormat("Y-m-d H:i:s", $this->getParameter("startDateTime"));
     $end = \DateTime::createFromFormat("Y-m-d H:i:s", $this->getParameter("endDateTime"));
     if ($start->getTimestamp() > $end->getTimestamp()) {
         // Swap both times
         list($start, $end) = array($end, $start);
     }
     if ($this->hasParameter("sampleSize")) {
         $sampleSize = $this->getParameter("sampleSize");
     } else {
         $sampleSize = 25;
     }
     $intervalSize = intval(($end->getTimestamp() - $start->getTimestamp()) / $sampleSize);
     $queryStartTime = clone $start;
     $queryEndTime = clone $start;
     $queryEndTime->add(new \DateInterval("PT" . $intervalSize . "S"));
     $partUnitQuery = "SELECT pu FROM PartKeepr\\Part\\PartUnit pu";
     $query = PartKeepr::getEM()->createQuery($partUnitQuery);
     $aPartUnits = $query->getResult();
     $aRecords = array();
     $dql = "SELECT AVG(sts.parts) AS parts, AVG(sts.categories) AS categories FROM PartKeepr\\Statistic\\StatisticSnapshot sts WHERE sts.dateTime >= :start AND sts.dateTime <= :end";
     $mainQuery = PartKeepr::getEM()->createQuery($dql);
     $dql = "SELECT AVG(stsu.stockLevel) AS stockLevel FROM PartKeepr\\Statistic\\StatisticSnapshotUnit stsu JOIN stsu.statisticSnapshot sts WHERE sts.dateTime >= :start AND sts.dateTime <= :end AND stsu.partUnit = :partUnit";
     $subQuery = PartKeepr::getEM()->createQuery($dql);
     for ($i = 0; $i < $sampleSize; $i++) {
         $mainQuery->setParameter("start", $queryStartTime);
         $mainQuery->setParameter("end", $queryEndTime);
         $result = $mainQuery->getResult();
         $record = $result[0];
         if ($record["parts"] !== null) {
             $record["parts"] = floatval($record["parts"]);
         }
         if ($record["categories"] !== null) {
             $record["categories"] = floatval($record["categories"]);
         }
         foreach ($aPartUnits as $partUnit) {
             $subQuery->setParameter("start", $queryStartTime);
             $subQuery->setParameter("end", $queryEndTime);
             $subQuery->setParameter("partUnit", $partUnit);
             $aResult = $subQuery->getResult();
             if ($aResult[0]["stockLevel"] !== null) {
                 $record["units"][$partUnit->getName()] = floatval($aResult[0]["stockLevel"]);
             } else {
                 $record["units"][$partUnit->getName()] = null;
             }
         }
         $record["start"] = $queryStartTime->format("Y-m-d H:i:s");
         if ($record["parts"] !== null) {
             $aRecords[] = $record;
         }
         $queryStartTime->add(new \DateInterval("PT" . $intervalSize . "S"));
         $queryEndTime->add(new \DateInterval("PT" . $intervalSize . "S"));
     }
     return array("status" => "ok", "data" => $aRecords);
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:70,代码来源:StatisticService.php

示例13: destroy

 public function destroy()
 {
     $this->requireParameter("id");
     $logo = ManufacturerICLogo::loadById($this->getParameter("id"));
     PartKeepr::getEM()->remove($logo);
     PartKeepr::getEM()->flush();
     return array("data" => null);
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:8,代码来源:PartDistributorService.php

示例14: destroy

 /**
  * (non-PHPdoc)
  * @see PartKeepr\Service.RestfulService::destroy()
  */
 public function destroy()
 {
     $this->requireParameter("id");
     $file = ProjectAttachment::loadById($this->getParameter("id"));
     PartKeepr::getEM()->remove($file);
     PartKeepr::getEM()->flush();
     return array("data" => null);
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:12,代码来源:ProjectAttachmentService.php

示例15: getByName

 /**
  * Gets an existing event by its name.
  * @param unknown $name
  */
 public function getByName($name)
 {
     $obj = PartKeepr::getEM()->getRepository('PartKeepr\\EventNotification\\Event')->findOneByName($name);
     if (!$obj) {
         throw new ObjectNotFoundException('PartKeepr\\EventNotification\\Event', "name={$name}");
     }
     return $obj;
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:12,代码来源:EventManager.php


注:本文中的PartKeepr\PartKeepr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。