setRelation() public method

public setRelation ( Relations $rel )
$rel Bolt\Storage\Collection\Relations
コード例 #1
0
ファイル: RecordModifier.php プロジェクト: edvardio/bolt
 /**
  * Convert POST relationship values to an array of Entity objects keyed by
  * ContentType.
  *
  * @param Content    $content
  * @param array|null $formValues
  */
 private function setPostedRelations(Content $content, $formValues)
 {
     if (!isset($formValues['relation'])) {
         return;
     }
     $entities = [];
     foreach ($formValues['relation'] as $contentType => $relations) {
         $repo = $this->app['storage']->getRepository($contentType);
         foreach ($relations as $id) {
             if ($relation = $repo->find($id)) {
                 $entities[$contentType][] = $relation;
             }
         }
     }
     $content->setRelation($entities);
 }