Ejemplo n.º 1
0
function bindTradingHourEntityArray($tradingHourEntitys)
{
    $tradingHourDtos = new TradingHourListDto();
    $tradingHourDtoArray = array();
    foreach ($tradingHourEntitys as $tradingHourEntity => $value) {
        array_push($tradingHourDtoArray, bindTradingHourEntity($value));
    }
    $tradingHourDtos->setTradingHours($tradingHourDtoArray);
    return $tradingHourDtos;
}
Ejemplo n.º 2
0
function bindTradingDayEntity($tradingDayEntity)
{
    if ($tradingDayEntity != null) {
        $tradingDayDto = new TradingDayDto();
        $tradingDayDto->setTradingDayId($tradingDayEntity->getTradingDayId());
        $tradingDayDto->setMonday(bindTradingHourEntity($tradingDayEntity->getMonday()));
        $tradingDayDto->setTuesday(bindTradingHourEntity($tradingDayEntity->getTuesday()));
        $tradingDayDto->setWednesday(bindTradingHourEntity($tradingDayEntity->getWednesday()));
        $tradingDayDto->setThursday(bindTradingHourEntity($tradingDayEntity->getThursday()));
        $tradingDayDto->setFriday(bindTradingHourEntity($tradingDayEntity->getFriday()));
        $tradingDayDto->setSaturday(bindTradingHourEntity($tradingDayEntity->getSaturday()));
        $tradingDayDto->setSunday(bindTradingHourEntity($tradingDayEntity->getSunday()));
        $tradingDayDto->setPubicHoliday(bindTradingHourEntity($tradingDayEntity->getPubicHoliday()));
        return $tradingDayDto;
    } else {
        return null;
    }
}
    $tradingHoursArray = array();
    foreach ($tradingHourListDto->getTradingHours() as $tradingHourDto) {
        $tradingHourEntity = bindTradingHourDto($tradingHourDto);
        $entityManager->persist($tradingHourEntity);
        $entityManager->flush();
        array_push($tradingHoursArray, bindTradingHourEntity($tradingHourEntity));
    }
    $tradingHourListDto = new TradingHourListDto();
    $tradingHourListDto->setTradingHours($tradingHoursArray);
    $tradingHourListDto->printData($app);
});
$app->put('/tradinghours/:id', function ($id) use($app) {
    global $entityManager;
    $tradingHourEntity = $entityManager->find("TradingHourEntity", $id);
    $entityManager->flush();
    $tradingHourDto = bindTradingHourEntity($tradingHourEntity);
    $tradingHourDto->printData($app);
});
$app->delete('/tradinghours/:id', function ($id) use($app) {
    global $entityManager;
    $tradingHourEntity = $entityManager->find("TradingHourEntity", $id);
    $entityManager->remove($tradingHourEntity);
    $entityManager->flush();
});
/*Referances*/
$app->get('/tradinghours/:id/tradingdays/mondays', function ($id) use($app) {
    global $entityManager;
    $tradingDayEntities = $entityManager->getRepository("TradingDayEntity")->findBy(array('monday' => $id));
    $tradingDay = bindTradingDayEntityArray($tradingDayEntities);
    $tradingDay->printData($app);
});