| @@ 8-38 (lines=31) @@ | ||
| 5 | use keeko\tools\generator\AbstractActionGenerator; |
|
| 6 | use Propel\Generator\Model\Table; |
|
| 7 | ||
| 8 | class ToManyRelationshipAddActionGenerator extends AbstractActionGenerator { |
|
| 9 | ||
| 10 | /** |
|
| 11 | * Add default blank methods |
|
| 12 | * |
|
| 13 | * @param PhpClass $class |
|
| 14 | */ |
|
| 15 | public function generate(PhpClass $class, Table $model, Table $foreignModel, Table $middle) { |
|
| 16 | // add use statements |
|
| 17 | $this->ensureBasicSetup($class); |
|
| 18 | ||
| 19 | // method: configureParams(OptionsResolver $resolver) |
|
| 20 | $this->addConfigureParamsMethod($class, $this->twig->render('relationship-configureParams.twig')); |
|
| 21 | ||
| 22 | // method: run(Request $request) : Response |
|
| 23 | $class->addUseStatement('Symfony\\Component\\HttpFoundation\\Request'); |
|
| 24 | $class->addUseStatement('Symfony\\Component\\HttpFoundation\\Response'); |
|
| 25 | $class->addUseStatement('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException'); |
|
| 26 | $class->addUseStatement('Tobscure\\JsonApi\\Exception\\InvalidParameterException'); |
|
| 27 | $class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName() . 'Query'); |
|
| 28 | $class->addUseStatement($model->getNamespace() . '\\' . $foreignModel->getPhpName() . 'Query'); |
|
| 29 | $class->setMethod($this->generateRunMethod($this->twig->render('to-many-add-run.twig', [ |
|
| 30 | 'model' => $model->getCamelCaseName(), |
|
| 31 | 'class' => $model->getPhpName(), |
|
| 32 | 'foreign_model' => $foreignModel->getCamelCaseName(), |
|
| 33 | 'foreign_class' => $foreignModel->getPhpName() |
|
| 34 | ]))); |
|
| 35 | ||
| 36 | return $class; |
|
| 37 | } |
|
| 38 | } |
|
| @@ 8-38 (lines=31) @@ | ||
| 5 | use keeko\tools\generator\AbstractActionGenerator; |
|
| 6 | use Propel\Generator\Model\Table; |
|
| 7 | ||
| 8 | class ToManyRelationshipRemoveActionGenerator extends AbstractActionGenerator { |
|
| 9 | ||
| 10 | /** |
|
| 11 | * Add default blank methods |
|
| 12 | * |
|
| 13 | * @param PhpClass $class |
|
| 14 | */ |
|
| 15 | public function generate(PhpClass $class, Table $model, Table $foreignModel, Table $middle) { |
|
| 16 | // add use statements |
|
| 17 | $this->ensureBasicSetup($class); |
|
| 18 | ||
| 19 | // method: configureParams(OptionsResolver $resolver) |
|
| 20 | $this->addConfigureParamsMethod($class, $this->twig->render('relationship-configureParams.twig')); |
|
| 21 | ||
| 22 | // method: run(Request $request) : Response |
|
| 23 | $class->addUseStatement('Symfony\\Component\\HttpFoundation\\Request'); |
|
| 24 | $class->addUseStatement('Symfony\\Component\\HttpFoundation\\Response'); |
|
| 25 | $class->addUseStatement('Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException'); |
|
| 26 | $class->addUseStatement('Tobscure\\JsonApi\\Exception\\InvalidParameterException'); |
|
| 27 | $class->addUseStatement($model->getNamespace() . '\\' . $model->getPhpName() . 'Query'); |
|
| 28 | $class->addUseStatement($model->getNamespace() . '\\' . $foreignModel->getPhpName() . 'Query'); |
|
| 29 | $class->setMethod($this->generateRunMethod($this->twig->render('to-many-delete-run.twig', [ |
|
| 30 | 'model' => $model->getCamelCaseName(), |
|
| 31 | 'class' => $model->getPhpName(), |
|
| 32 | 'foreign_model' => $foreignModel->getCamelCaseName(), |
|
| 33 | 'foreign_class' => $foreignModel->getPhpName() |
|
| 34 | ]))); |
|
| 35 | ||
| 36 | return $class; |
|
| 37 | } |
|
| 38 | } |
|