Makes a block shared and creates a pointer block in it's place

This method performs the change and persists/flushes to the database.

@param integer $id

@return BlockPointer
970535
public function makeBlockShared($id)
    {
        $block = $this->find($id, true);
        $this->publish($block);

        // Duplicate some of the settings to the pointer
        $pointer = new PointerBlock();
        $pointer->setOwner($block->getOwner());
        $pointer->setParent($block->getParent());
        $pointer->setPosition($block->getPosition());
        $pointer->setSort($block->getSort());
        $pointer->setReference($block);
        $pointer->setDraft(true);

        // Detach and make shared
        $block->setShared(true);
        $block->setSharedName(sprintf('%s_%s', $block->getBlockType(), $block->getOwner()->getId()));
        $block->setSharedDisplayName(sprintf('%s from %s', $block->getBlockType(), $block->getOwnerName()));
        $block->setParent(null);
        $block->setOwner(null);
        $block->setPosition(null);
        $block->setSort(null);

        $this->save($block, false)->save($pointer);

        if ($block instanceof CompositeBlock) {
            $iterator = new \RecursiveIteratorIterator(
                new RecursiveBlockIterator($block->getChildren()),
                \RecursiveIteratorIterator::SELF_FIRST
            );

            foreach ($iterator as $child) {
                $child->setOwner(null);
                $this->publish($child);
                $this->save($child, false);
            }
        }

        return $pointer;
    }
475671
public function update($id)
    {
        $block = $this->repository->getById($id);
        if (!empty($block)) {
            $this->authorize('update', $block);
            $input = $this->validator->validate('update');
            $block = $this->repository->update($block, $input, auth()->user());
            return $this->respondWithSuccess($block, new BlockTransformer);
        }
        return $this->respondNotFound();
    }
610786
public function newPivotStatementForId($id)
    {
        $pivot = $this->newPivotStatement();

        $parentKeyName = $this->parentMap->getKeyName();

        $key = $this->parent->getEntityAttribute($parentKeyName);

        return $pivot->where($this->foreignKey, $key)->where($this->otherKey, $id);
    }
1287857
public function setId($id)
    {
        if (!is_null($id)) {
            $id = (string) $id;
        }

        $this->id = $id;
        return $this;
    }
280416
public function flushDbAction($id)
    {
        try {
            $this->getWorker()->flushDB($id);
            
            $this->get('session')->getFlashBag()->add('success', 'Flush DB on '.$id.' executed successfully');
        }catch(\Exception $e) {
            $this->get('session')->getFlashBag()->add('success', 'Une erreur s\'est produite : '.$e->getMessage());
        }
        
        return new RedirectResponse($this->generateUrl('ringo_php_redmon'));
    }
533672
public function editBlockAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('AmulenPageBundle:Block')->find($id);
        $availableEntityLangs = $em->getRepository('AmulenPageBundle:Block')->findBy(array('page' => $entity->getPage(), 'name' => $entity->getName()));

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Block entity.');
        }

        $editForm = $this->createBlockEditForm($entity);
        $deleteForm = $this->createBlockDeleteForm($id);

        return array(
            'entity' => $entity,
            'availableEntityLangs' => $availableEntityLangs,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
1112388
public function edit($id)
    {
        $this->builder->setMode(Builder::MODE_EDIT);
        $this->builder->setResourceId($id);

        $this->setFieldValue($id);

        return $this;
    }
847760
public function show($id)
    {
        $block = $this->repository->getById($id);
        if (!empty($block)) {
            $this->authorize('read', $block);
            return $this->respondWithSuccess($block, new BlockTransformer);
        }
        return $this->respondNotFound();
    }
517305
protected function addAdditionalBlockPrefixOption($id, array &$options)
    {
        if ($this->hasNamespacePlaceholder($id)) {
            $options[self::ADDITIONAL_BLOCK_PREFIX_OPTION] = $this->getAdditionalBlockPrefixes($id, $this->import);
        }

        return $this;
    }
1000491
public function setId(int $id): Website
    {
        Assert::greaterThan($id, 0);

        $this->id = $id;

        return $this;
    }
527769
public static function markResolved($id) {
		$db = Factory::getDBO();

		$query = $db->getQuery(true)
			->update('#__jfusion_sync_details')
			->set('action = ' . $db->quote('resolved'))
			->where('id = ' . $db->quote($id));

		$db->setQuery($query);
		$db->execute();
	}
590100
public function delete(int $id): ArticleEndpointInterface
    {
        $this->shopware()->delete('/api/articles/' . (string)$id);

        return $this;
    }
668096
public function setId($id)
    {
        if (!$this->setHeaderFieldModel($this->getIdField(), $id)) {
            $this->headers->addIdHeader($this->getIdField(), $id);
        }
        $this->id = $id;

        return $this;
    }
1276723
public function setId($id)
    {
        $this->id = (integer)$id;
        $this->hasId = true;

        return $this;
    }
1193213
public function setHandler($id)
    {
        if (is_string($id)) {
            $this->handler = $this->file->getHandler($id);
        } else {
            $this->handler = $id;
        }

        return $this;
    }
1214570
public function getContentIdByBlockId($id)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select($this->connection->quoteIdentifier('contentobject_id'))
            ->from($this->connection->quoteIdentifier('ezcontentobject_tree'), 't')
            ->innerJoin(
                't',
                $this->connection->quoteIdentifier(self::EZM_BLOCK_TABLE),
                'b',
                $query->expr()->eq(
                    $this->connection->quoteIdentifier('b.node_id'),
                    $this->connection->quoteIdentifier('t.node_id')
                )
            )
            ->where(
                $query->expr()->eq($this->connection->quoteIdentifier('b.id'), ':id')
            )
            ->setParameter(':id', $id, PDO::PARAM_STR)
        ;

        $statement = $query->execute();

        $contentId = $statement->fetchColumn();
        if ($contentId === false) {
            throw new NotFoundException('Block', $id);
        }

        return $contentId;
    }
206970
public function deleteDirectory(string $id): self
    {
        $this->filesystem->deleteDir($this->getDirectoryPath($id));
        unset($this->directories[$id]);

        return $this;
    }