Update the configuration for a block.

@param ServerRequestInterface $request
@param int     $block_id

@return void
516143
public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void
    {
        $this->setBlockSetting($block_id, 'days', $request->get('days', self::DEFAULT_DAYS));
        $this->setBlockSetting($block_id, 'infoStyle', $request->get('infoStyle', self::DEFAULT_STYLE));
        $this->setBlockSetting($block_id, 'calendar', $request->get('calendar', self::DEFAULT_CALENDAR));
    }
105033
void storeBlock(BlockId blockId, ByteBuffer block) throws IOException {
        synchronized (m_accessLock) {
            if (m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to store block that is already stored: "
                                                    + blockId.toString());
            }

            int origPosition = block.position();
            block.position(0);
            Path blockPath = makeBlockPath(blockId);
            try (SeekableByteChannel channel = Files.newByteChannel(blockPath, OPEN_OPTIONS, PERMISSIONS)) {
                channel.write(block);
            }
            finally {
                block.position(origPosition);
            }

            m_blockPathMap.put(blockId, blockPath);
        }
    }
1245258
def update_value(self, block_id, field, value):
        """""""
        block_name = self._db.get_block(block_id)
        for name in block_name:
            self._db.set_value(name, field, value)
321523
protected function buildBlock($id)
    {
        $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true);
        $options   = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true);
        $types     = $this->typeHelper->getTypes($blockType);

        $this->setBlockResolvedOptions($id, $blockType, $options, $types);
    }
795974
public function updateLayoutBlockSortAction( Request $request ) {
		$zones  = $request->get( 'zones', [] );
		$pageId = $request->get( 'pageId' );
		$code = $request->get( 'code' );

		if ( ! $pageId ) {
			throw $this->createNotFoundException();
		}
		$pageAdmin = $this->container->get( $code );
		foreach ( $zones as $zone ) {
			$zoneName = $zone['zone'];
			if ( array_key_exists( 'layoutBlocks', $zone ) && is_array( $zone['layoutBlocks'] ) ) {
				foreach ( $zone['layoutBlocks'] as $key => $layoutBlockStr ) {
					$sort    = ++ $key;
					$blockId = str_replace( 'layoutBlock_', '', $layoutBlockStr );

					if ( $blockId ) {
						try {
							/** @var \Networking\InitCmsBundle\Model\LayoutBlockInterface $layoutBlock */
							$layoutBlock = $this->admin->getObject( $blockId );
							if ( $layoutBlock ) {
								$layoutBlock->setSortOrder( $sort );
								$layoutBlock->setZone( $zoneName );
							}

							$this->admin->update( $layoutBlock );
						} catch ( \Exception $e ) {
							$message = $e->getMessage();

							return new JsonResponse( [ 'messageStatus' => 'error', 'message' => $message ] );
						}
					}
				}
			}
		}


		$page = $pageAdmin->getModelManager()->find( $pageAdmin->getClass(), $pageId );
		$pageAdmin->setSubject( $page );

		$pageStatus = $this->renderView(
			'@NetworkingInitCms/PageAdmin/page_status_settings.html.twig',
			[ 'admin' => $pageAdmin, 'object' => $page ] );

		$data = [
			'pageStatusSettings' => $pageStatus,
			'pageStatus'         => $this->translate( $page->getStatus() ),
			'messageStatus'      => 'success',
			'message'            => $this->translate( 'message.layout_blocks_sorted', [ 'zone' => '' ] ),
		];

		return new JsonResponse( $data );
	}
78190
public function editBlockAction(Request $request, $id, $version = 0)
    {
        $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');

        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');
        $version = $manager->getNewVersion($manager->find($id));

//        if ((int) $rootVersion !== $newVersion) {
//            throw new \Exception("Only new versions can be editted. New version is {$newVersion} while you requested {$rootVersion}");
//        }

        $block = $manager->find($id, $version);

        /** @var BlockServiceInterface $service */
        $service = $manager->getService($block);
        $block->setRootVersion($version);

        $updatePreview = false; // signals parent window preview from iframe to update preview

        $service->preFormSubmit($block);

        $form = $this->createForm(new BlockAdapterFormType($service), $block);
        $form->handleRequest($request);

        if ($form->isValid()) {

            $service->postFormSubmit($form, $block);

            $manager->save($block);
            $updatePreview = true;
        }

        return $this->render($service->getEditView(), [
            'block_service' => $service,
            'block' => $block,
            'form' => $form->createView(),
            'update_preview' => $updatePreview
        ]);
    }
478559
public function store(Request $request, $contentId, $blockTypeId)
    {
        try {
            list($content, $blockType, $block) = array_values($this->contentBlocks->save($request, $contentId, $blockTypeId));
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => trans('soda::terminology.block')]));
        }

        return redirect()->route('soda.content.edit', [$contentId, 'tab' => $this->getTab($blockType)])->with('success', trans('soda::messages.created', ['object' => trans('soda::terminology.block')]));
    }
1316503
public function blocksAction($page_id)
    {
        $em = $this->getDoctrine()->getManager();
        $availableLangs = $this->container->getParameter('flowcode_page.available_languages');
        $entities = array();
        $types = array("type_html", "type_text");
        foreach ($availableLangs as $key => $value) {
            $entities[] = array(
                'lang' => $key,
                'blocks' => $em->getRepository('AmulenPageBundle:Block')->findBlockByPageAndLangAndInType($page_id, $value, $types)
            );
        }
        $page = $em->getRepository('AmulenPageBundle:Page')->find($page_id);

        return array(
            'page' => $page,
            'entities' => $entities,
        );
    }
469039
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $num       = $this->getBlockSetting($block_id, 'num', self::DEFAULT_NUMBER);
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_STYLE);

        $info_styles = [
            /* I18N: An option in a list-box */
            'list'     => I18N::translate('bullet list'),
            /* I18N: An option in a list-box */
            'array'    => I18N::translate('compact list'),
            /* I18N: An option in a list-box */
            'table'    => I18N::translate('table'),
            /* I18N: An option in a list-box */
            'tagcloud' => I18N::translate('tag cloud'),
        ];

        echo view('modules/top10_surnames/config', [
            'num'         => $num,
            'infoStyle'   => $infoStyle,
            'info_styles' => $info_styles,
        ]);
    }
1047564
public function update(RoleRequest $request, $id)
    {
        $role = Role::findOrFail($id);

        $role->update($request->all());
        $role->setPermissions($request->permissions);
    }
980514
public function update(User $user, Block $block)
    {

        if ($user->canDo('block.block.update') && $user->isAdmin()) {
            return true;
        }

        return $user->id == $block->user_id;
    }
241642
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $show_last_update     = $this->getBlockSetting($block_id, 'show_last_update', '1');
        $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
        $number_of_surnames   = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES);
        $stat_indi            = $this->getBlockSetting($block_id, 'stat_indi', '1');
        $stat_fam             = $this->getBlockSetting($block_id, 'stat_fam', '1');
        $stat_sour            = $this->getBlockSetting($block_id, 'stat_sour', '1');
        $stat_media           = $this->getBlockSetting($block_id, 'stat_media', '1');
        $stat_repo            = $this->getBlockSetting($block_id, 'stat_repo', '1');
        $stat_surname         = $this->getBlockSetting($block_id, 'stat_surname', '1');
        $stat_events          = $this->getBlockSetting($block_id, 'stat_events', '1');
        $stat_users           = $this->getBlockSetting($block_id, 'stat_users', '1');
        $stat_first_birth     = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
        $stat_last_birth      = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
        $stat_first_death     = $this->getBlockSetting($block_id, 'stat_first_death', '1');
        $stat_last_death      = $this->getBlockSetting($block_id, 'stat_last_death', '1');
        $stat_long_life       = $this->getBlockSetting($block_id, 'stat_long_life', '1');
        $stat_avg_life        = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
        $stat_most_chil       = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
        $stat_avg_chil        = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');

        echo view('modules/gedcom_stats/config', [
            'show_last_update'     => $show_last_update,
            'show_common_surnames' => $show_common_surnames,
            'number_of_surnames'   => $number_of_surnames,
            'stat_indi'            => $stat_indi,
            'stat_fam'             => $stat_fam,
            'stat_sour'            => $stat_sour,
            'stat_media'           => $stat_media,
            'stat_repo'            => $stat_repo,
            'stat_surname'         => $stat_surname,
            'stat_events'          => $stat_events,
            'stat_users'           => $stat_users,
            'stat_first_birth'     => $stat_first_birth,
            'stat_last_birth'      => $stat_last_birth,
            'stat_first_death'     => $stat_first_death,
            'stat_last_death'      => $stat_last_death,
            'stat_long_life'       => $stat_long_life,
            'stat_avg_life'        => $stat_avg_life,
            'stat_most_chil'       => $stat_most_chil,
            'stat_avg_chil'        => $stat_avg_chil,
        ]);
    }
416917
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $days      = (int) $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
        $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
        $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);

        $info_styles = [
            /* I18N: An option in a list-box */
            'list'  => I18N::translate('list'),
            /* I18N: An option in a list-box */
            'table' => I18N::translate('table'),
        ];

        $sort_styles = [
            /* I18N: An option in a list-box */
            'name'      => I18N::translate('sort by name'),
            /* I18N: An option in a list-box */
            'date_asc'  => I18N::translate('sort by date, oldest first'),
            /* I18N: An option in a list-box */
            'date_desc' => I18N::translate('sort by date, newest first'),
        ];

        echo view('modules/recent_changes/config', [
            'days'        => $days,
            'infoStyle'   => $infoStyle,
            'info_styles' => $info_styles,
            'max_days'    => self::MAX_DAYS,
            'sortStyle'   => $sortStyle,
            'sort_styles' => $sort_styles,
            'show_user'   => $show_user,
        ]);
    }
1008540
protected function setResponseHeaders(BlockInterface $block, Response $response)
    {
        if ($block && $block->getReference()) {
            if ($this->getReferenceService($block)->isEsiEnabled($block->getReference())) {
                $this->getReferenceService($block)->setResponseHeaders($block->getReference(), $response);
            } else {
                $response->setLastModified($block->getReference()->getUpdatedAt());
                $response->setPublic();
            }
        }
    }
495402
public function renderAction(Request $request)
    {

        //TODO: render initial block via ajax
        $blockType = $request->get('blockType', null);
        $action    = $request->get('action', null);

        // merge all parameters
        $params = array_merge($request->request->all(), $request->query->all());

        // load block service
        $block = $this->getBlockServiceManager()->getService($blockType);
        if (!$block) {
            throw $this->createNotFoundException(sprintf('Cannot find block service "%s"', $blockType));
        }

        if(!$block instanceof AbstractAdminBlockService) {
            throw new \Exception('Block should be an instance of AbstractAdminBlockService');
        }

        $params['block'] = $block;

        $methodName = sprintf("%sAction", $action);

        if (!is_callable(array($block, $methodName), false)) {
            throw $this->createNotFoundException(sprintf('Cannot find method "%s" in block service "%s"', $methodName, $blockType));
        }

        return call_user_func_array(array($block, $methodName), array($request, $params));
    }
753044
public function execute(Request $request, $pageId, $blockId)
    {
        $cmsManager = $this->cmsManagerSelector->retrieve();

        $page = $cmsManager->getPageById($pageId);
        $block = $cmsManager->getBlock($blockId);

        if (!$block instanceof BlockInterface) {
            throw new BlockNotFoundException(sprintf('Unable to find block identifier "%s" in page "%s".', $blockId, $pageId));
        }

        $blockContext = $this->contextManager->get($block);

        return $this->blockRenderer->render($blockContext);
    }
886533
public function userPageUserUpdate(ServerRequestInterface $request): ResponseInterface
    {
        $user_id     = (int) $request->get('user_id');
        $main_blocks = (array) $request->get('main');
        $side_blocks = (array) $request->get('side');

        $this->updateUserBlocks($user_id, $main_blocks, $side_blocks);

        return redirect(route('admin-control-panel'));
    }