Card::createBlock

@return Body
970540
public function createBlock()
    {
        $this->childNodes->push(new Body());

        return $this->block = $this->childNodes->last();
    }
203214
public function createBlock($component, array $attributes = array())
    {
        $siteManager = $this->container->get('open_orchestra_display.manager.context');
        $displayBlockManager = $this->container->get('open_orchestra_display.display_block_manager');
        $blockClass = $this->container->getParameter('open_orchestra_model.document.block.class');

        /** @var BlockInterface $block */
        $block = new $blockClass;
        $block->setComponent($component);
        $block->setId(uniqid(BlockInterface::TEMP_ID_PREFIX));
        $block->setTransverse(false);
        $block->setSiteId($siteManager->getSiteId());
        $block->setLanguage($siteManager->getSiteLanguage());
        $block->setAttributes($attributes);

        return $displayBlockManager->show($block)->getContent();
    }
1191412
public function createBlockAction(Request $request)
    {
        $row = $this->findRowByRequest($request);
        $type = $request->request->get('type', null);

        try {
            $block = $this->getEditor()->createDefaultBlock($type, [], $row);
        } catch (EditorExceptionInterface $e) {
            return $this->handleException($e);
        }

        $this->validate($row);
        $this->persist($row);

        $viewBuilder = $this->getViewBuilder();

        $data = [
            'created' => $viewBuilder->buildBlock($block)->getAttributes()->getId(),
            'rows'    => [$viewBuilder->buildRow($row)],
        ];

        return $this->buildResponse($data, self::SERIALIZE_FULL);
    }
589136
public function newBlockCreateStruct(BlockDefinitionInterface $blockDefinition): BlockCreateStruct
    {
        $viewTypeIdentifier = $blockDefinition->getViewTypeIdentifiers()[0];
        $viewType = $blockDefinition->getViewType($viewTypeIdentifier);
        $itemViewTypeIdentifier = $viewType->getItemViewTypeIdentifiers()[0];

        $blockCreateStruct = new BlockCreateStruct($blockDefinition);
        $blockCreateStruct->viewType = $viewTypeIdentifier;
        $blockCreateStruct->itemViewType = $itemViewTypeIdentifier;
        $blockCreateStruct->isTranslatable = $blockDefinition->isTranslatable();
        $blockCreateStruct->alwaysAvailable = true;

        return $blockCreateStruct;
    }
1072168
def create_block(mc, block_id, subtype=None):
    
    # Get player tile position and real position.
    ptx, pty, ptz = mc.player.getTilePos()
    px, py, pz = mc.player.getPos()
    # Create block at current player tile location.
    if subtype is None:
        mc.setBlock(ptx, pty, ptz, block_id)
    else:
        mc.setBlock(ptx, pty, ptz, block_id, subtype)
    # Move the player's real positon up one block.
    mc.player.setPos(px, py+1, pz)
993616
private function cardBody() : string
    {
        if (count($this->body_sections) === 0) {
            if ($this->body !== null) {
                $body = $this->body;
            } else {
                $body = '<p>No card body content defined, no calls to setBody() or setBodyContent().</p>';
            }
        } else {
            $body = $this->cardBodyHtml();
        }

        return '<div class="card-body' . $this->elementClasses('body') . '"' .
            $this->elementAttr('body') . '>' . $body . '</div>';
    }
9796
public function CreateBody() {
    $body = '';

    if ($this->sign_key_file) {
      $body .= $this->GetMailMIME().$this->LE;
    }

    $this->SetWordWrap();

    switch($this->message_type) {
      case 'inline':
        $body .= $this->GetBoundary($this->boundary[1], '', '', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->AttachAll("inline", $this->boundary[1]);
        break;
      case 'attach':
        $body .= $this->GetBoundary($this->boundary[1], '', '', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->AttachAll("attachment", $this->boundary[1]);
        break;
      case 'inline_attach':
        $body .= $this->TextLine("--" . $this->boundary[1]);
        $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
        $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
        $body .= $this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', '', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->AttachAll("inline", $this->boundary[2]);
        $body .= $this->LE;
        $body .= $this->AttachAll("attachment", $this->boundary[1]);
        break;
      case 'alt':
        $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->EndBoundary($this->boundary[1]);
        break;
      case 'alt_inline':
        $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->TextLine("--" . $this->boundary[1]);
        $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
        $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
        $body .= $this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->AttachAll("inline", $this->boundary[2]);
        $body .= $this->LE;
        $body .= $this->EndBoundary($this->boundary[1]);
        break;
      case 'alt_attach':
        $body .= $this->TextLine("--" . $this->boundary[1]);
        $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
        $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
        $body .= $this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->EndBoundary($this->boundary[2]);
        $body .= $this->LE;
        $body .= $this->AttachAll("attachment", $this->boundary[1]);
        break;
      case 'alt_inline_attach':
        $body .= $this->TextLine("--" . $this->boundary[1]);
        $body .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
        $body .= $this->TextLine("\tboundary=\"" . $this->boundary[2] . '"');
        $body .= $this->LE;
        $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '');
        $body .= $this->EncodeString($this->AltBody, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->TextLine("--" . $this->boundary[2]);
        $body .= $this->HeaderLine('Content-Type', 'multipart/related;');
        $body .= $this->TextLine("\tboundary=\"" . $this->boundary[3] . '"');
        $body .= $this->LE;
        $body .= $this->GetBoundary($this->boundary[3], '', 'text/html', '');
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        $body .= $this->LE.$this->LE;
        $body .= $this->AttachAll("inline", $this->boundary[3]);
        $body .= $this->LE;
        $body .= $this->EndBoundary($this->boundary[2]);
        $body .= $this->LE;
        $body .= $this->AttachAll("attachment", $this->boundary[1]);
        break;
      default:
        // catch case 'plain' and case ''
        $body .= $this->EncodeString($this->Body, $this->Encoding);
        break;
    }

    if ($this->IsError()) {
      $body = '';
    } elseif ($this->sign_key_file) {
      try {
        $file = tempnam('', 'mail');
        file_put_contents($file, $body); //TODO check this worked
        $signed = tempnam("", "signed");
        if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
          @unlink($file);
          $body = file_get_contents($signed);
          @unlink($signed);
        } else {
          @unlink($file);
          @unlink($signed);
          throw new phpmailerException($this->Lang("signing").openssl_error_string());
        }
      } catch (phpmailerException $e) {
        $body = '';
        if ($this->exceptions) {
          throw $e;
        }
      }
    }

    return $body;
  }
186472
protected function createResponse(BlockContextInterface $blockContext, Response $response = null)
    {
        if (null === $response) {
            $response = new Response();
        }

        // set the ttl from the block instance, this can be changed by the BlockService
        if (($ttl = $blockContext->getBlock()->getTtl()) > 0) {
            $response->setTtl($ttl);
        }

        return $response;
    }
19550
public function create()
    {
        /**
         * @var BannerZoneInterface $bannerZone
         */
        $classNamespace = $this->getEntityNamespace();
        $bannerZone = new $classNamespace();
        $bannerZone->setBanners(new ArrayCollection());

        return $bannerZone;
    }
1200963
public function initializeBlock($component, $siteId, $language, $isTransverse)
    {
        /** @var BlockInterface $block */
        $block = new $this->blockClass();
        $block->setComponent($component);
        $block->setTransverse($isTransverse);
        $block->setSiteId($siteId);
        $block->setLanguage($language);
        $this->setDefaultAttributes($block);

        return $block;
    }
609961
public function newBlockAction($page_id, $type)
    {
        $em = $this->getDoctrine()->getManager();
        $page = $em->getRepository('AmulenPageBundle:Page')->find($page_id);

        $entity = new Block();
        $entity->setType($type);
        $entity->setPage($page);
        $form = $this->createBlockCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
798809
public function newAction() {
        $entity = new Block();
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
1114315
public function generateDocblock() {
		$docblock = $this->getDocblock();
		$docblock->setShortDescription($this->getDescription());
		$docblock->setLongDescription($this->getLongDescription());

		foreach ($this->methods as $method) {
			$method->generateDocblock();
		}

		return $this;
	}
1122696
public function handleBlock()
    {
        if ($id = $this->owner->getRequest()->param('ID')) {
            $blocks = $this->owner->data()->getBlockList(null, true, true, true);
            if ($block = $blocks->find('ID', $id)) {
                return $block->getController();
            }
        }

        return $block->getController();
    }
204026
protected function CreateSetup($block)
	{
		if ($this->_action == ModuleAction::CreateConfirm)
		{
			$p = new XmlParagraphCollection();
			if ($this->_context->get("type")!="-anydata-")
			{
				try 
				{
					$tblpoll = $this->_context->get("tbl_poll");
					$tblanswer = $this->_context->get("tbl_answer");
					$tbllastip = $this->_context->get("tbl_lastip");
					$suffix = $this->_context->get("tablesuffix");
					
					$dbdata = new DBDataset($this->_context->get("type"));
					$results = array();
					$results[] = $this->CreateTable($dbdata, "create table $tblpoll", "create table $tblpoll (name varchar(15), lang char(5), question varchar(150), multiple char(1), showresults char(1), active char(1)) $suffix");
					$results[] = $this->CreateTable($dbdata, "create table $tblanswer", "create table $tblanswer (name varchar(15), lang char(5), code int, short varchar(10), answer varchar(50), votes int) $suffix");
					//$results[] = $this->CreateTable($dbdata, "create table $tbllastip", "create table $tbllastip (name varchar(15), ip varchar(15)) $suffix");
					$results[] = $this->CreateTable($dbdata, "add primary key poll", "alter table $tblpoll add constraint pk_poll primary key (name, lang);");
					$results[] = $this->CreateTable($dbdata, "add primary key answer", "alter table $tblanswer add constraint pk_answer primary key (name, lang, code)");
					//$results[] = $this->CreateTable($dbdata, "add primary key lastip", "alter table $tbllastip add constraint pk_lastip primary key (name, ip)");
					$results[] = $this->CreateTable($dbdata, "add check poll 1", "alter table $tblpoll add constraint ck_poll_multiple check (multiple in ('Y', 'N'))");
					$results[] = $this->CreateTable($dbdata, "add check poll 2", "alter table $tblpoll add constraint ck_poll_showresults check (showresults in ('Y', 'N'))");
					$results[] = $this->CreateTable($dbdata, "add check poll 3", "alter table $tblpoll add constraint ck_poll_active check (active in ('Y', 'N'))");
					$results[] = $this->CreateTable($dbdata, "add foreign key answer", "alter table $tblanswer add constraint pk_answer_poll foreign key (name) references $tblpoll(name)");
					//$results[] = $this->CreateTable($dbdata, "add foreign key lastip", "alter table $tbllastip add constraint pk_lastip_poll foreign key (name) references $tblpoll(name)");
					
					$block->addXmlnukeObject(new XmlEasyList(EasyListType::UNORDEREDLIST, "", $this->myWords->Value("RESULTSQL"), $results));

					$poll = new AnydatasetFilenameProcessor("_poll");
					$anypoll = new AnyDataset($poll);
					$anypoll->appendRow();
					$anypoll->addField("dbname", $this->_context->get("type"));
					$anypoll->addField("tbl_poll", $tblpoll);
					$anypoll->addField("tbl_answer", $tblanswer);
					$anypoll->addField("tbl_lastip", $tbllastip);
					$anypoll->Save();
				}
				catch (Exception $ex)
				{
					$p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("GOTERROR", $ex->getMessage())));
				}
			}
			else 
			{
				$poll = new AnydatasetFilenameProcessor("_poll");
				$anypoll = new AnyDataset($poll);
				$anypoll->appendRow();
				$anypoll->addField("dbname", "-anydata-");
				$anypoll->Save();
			}
			$p->addXmlnukeObject(new XmlnukeBreakLine());
			$p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CONFIGCREATED"), true));
			$block->addXmlnukeObject($p);
		}
		else 
		{
			$p = new XmlParagraphCollection();
			$p->addXmlnukeObject(new XmlnukeText($this->myWords->Value("FIRSTTIMEMESSAGE")));
			$block->addXmlnukeObject($p);
			
			$form = new XmlFormCollection($this->_context, $this->_moduleUrl, $this->myWords->Value("CREATESETUP"));
			$form->addXmlnukeObject(new XmlInputHidden("action", ModuleAction::CreateConfirm));
			$db = array("-anydata-"=>$this->myWords->Value("NOTUSEDB"));
			$anydatafile = new AnydatasetFilenameProcessor("_db");
			$anydata = new AnyDataset($anydatafile->FullQualifiedNameAndPath());
			$it = $anydata->getIterator();
			while ($it->hasNext())
			{
				$sr = $it->moveNext();
				$db[$sr->getField("dbname")] = $sr->getField("dbname");
			}
			$form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "type", $this->myWords->Value("FORMCONN"), $db));
			
			$inputGroup = new XmlInputGroup($this->_context, "tabledetail", true);
			$inputGroup->setVisible(false);
			
			$text = new XmlInputTextBox($this->myWords->Value("TABLENAME_POLL"), "tbl_poll", "xmlnuke_poll", 20);
			$text->setRequired(true);
			$inputGroup->addXmlnukeObject($text);
			
			$text = new XmlInputTextBox($this->myWords->Value("TABLENAME_ANSWER"), "tbl_answer", "xmlnuke_answer", 20);
			$text->setRequired(true);
			$inputGroup->addXmlnukeObject($text);
			
			$text = new XmlInputTextBox($this->myWords->Value("TABLENAME_LASTIP"), "tbl_lastip", "xmlnuke_lastip", 20);
			$text->setRequired(true);
			$inputGroup->addXmlnukeObject($text);
			
			$text = new XmlInputTextBox($this->myWords->Value("TABLE_SUFFIX"), "tablesuffix", "TYPE INNODB", 30);
			$text->setRequired(true);
			$inputGroup->addXmlnukeObject($text);
			
			$form->addXmlnukeObject($inputGroup);
			
			$buttons = new XmlInputButtons();
			$buttons->addSubmit($this->myWords->Value("CREATESETUPBTN"));
			$form->addXmlnukeObject($buttons);
			
			$block->addXmlnukeObject($form);
			
			$javascript = 
				"
				// ByJG 
				fn_addEvent('type', 'change', enableFields);
				function enableFields(e) {
		    		obj = document.getElementById('type');
		    		showHide_tabledetail(obj.selectedIndex != 0);
				}
				";
			$this->defaultXmlnukeDocument->addJavaScriptSource($javascript, true);
			
		}
			
	}
1102524
public function generateBody()
    {
        $result = $this->addHeadersSection( $this->message ) . ezcMailTools::lineBreak();
        for ( $i = 0; $i < count( $this->recipients ); $i++ )
        {
            $result .= $this->addHeadersSection( $this->recipients[$i] ) . ezcMailTools::lineBreak();
        }
        return $result;
    }
1052169
protected function makeCurlBody() {
        $body = $this->body;

        if (is_string($body)) {
            return (string)$body;
        }

        $contentType = $this->getHeader('Content-Type');
        if (stripos($contentType, 'application/json') === 0) {
            $body = json_encode($body);
        }

        return $body;
    }