PHP code example of ucsf / restorm-bundle
1. Go to this page and download the library: Download ucsf/restorm-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ucsf / restorm-bundle example snippets
use UCSF\RestOrmBundle\Doctrine\ORM\EntityManager;
use NiceCompany\AwesomeBundle\Entity\Widget;
use NiceCompany\AwesomeBundle\Entity\Factory;
class WidgetService
{
private $entityManager;
private $widgetRepository;
public function __construct(EntityManager $entityManager) {
$this->entityManager = $entityManager;
$this->widgetRepository = $entityManager->getRepository(Widget::class);
$this->factoryRepository = $entityManager->getRepository(Factory::class);
}
// Using repositories
public function getWidgetById($id) {
return $this->roleRepository->findById($id);
}
public function saveWidget(Widget $widget) {
return $this->entityManager->persist($widget);
}
// Using commands
public function getWidgetsByFactory($widgetId) {
return $this->entityManager->command('get_widgets_by_factory', ['widgetId' => $widgetId]);
}
public function deleteWidget(Widget $widget) {
return $this->entityManager->command('delete_widget', [] /* null is fine too */, $widget);
}