concrete/src/Entity/Block/BlockType/BlockType.php
public function add($data, $c = false, $a = false)
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();

        $u = new User();
        if (isset($data['uID'])) {
            $uID = $data['uID'];
        } else {
            $uID = $u->getUserID();
        }
        $bName = '';
        if (isset($data['bName'])) {
            $bName = $data['bName'];
        }

        $btID = $this->btID;
        $dh = $app->make('helper/date');
        $bDate = $dh->getOverridableNow();
        $bIsActive = (isset($this->btActiveWhenAdded) && $this->btActiveWhenAdded == 1) ? 1 : 0;

        $v = array($bName, $bDate, $bDate, $bIsActive, $btID, $uID);
        $q = "insert into Blocks (bName, bDateAdded, bDateModified, bIsActive, btID, uID) values (?, ?, ?, ?, ?, ?)";

        $res = $db->executeQuery($q, $v);

        // we get the block object for the block we just added
        if ($res) {
            $bIDnew = $db->lastInsertId();

            $nb = Block::getByID($bIDnew);
            if (is_object($c)) {
                $nb->setBlockCollectionObject($c);
            }
            if (is_object($a)) {
                $nb->setBlockAreaObject($a);
            }
            $class = $this->getBlockTypeClass();
            $bc = $app->build($class, [$nb]);
            $bc->save($data);

            return Block::getByID($bIDnew);
        }
    }
public function add($data, $c = false, $a = false)
    {
        $app = Facade::getFacadeApplication();
        $db = $app->make('database')->connection();

        $u = new User();
        if (isset($data['uID'])) {
            $uID = $data['uID'];
        } else {
            $uID = $u->getUserID();
        }
        $bName = '';
        if (isset($data['bName'])) {
            $bName = $data['bName'];
        }

        $btID = $this->btID;
        $dh = $app->make('helper/date');
        $bDate = $dh->getOverridableNow();
        $bIsActive = (isset($this->btActiveWhenAdded) && $this->btActiveWhenAdded == 1) ? 1 : 0;

        $v = array($bName, $bDate, $bDate, $bIsActive, $btID, $uID);
        $q = "insert into Blocks (bName, bDateAdded, bDateModified, bIsActive, btID, uID) values (?, ?, ?, ?, ?, ?)";

        $res = $db->executeQuery($q, $v);

        // we get the block object for the block we just added
        if ($res) {
            $bIDnew = $db->lastInsertId();

            $nb = Block::getByID($bIDnew);
            if (is_object($c)) {
                $nb->setBlockCollectionObject($c);
            }
            if (is_object($a)) {
                $nb->setBlockAreaObject($a);
            }
            $class = $this->getBlockTypeClass();
            $bc = $app->build($class, [$nb]);
            $bc->save($data);

            return Block::getByID($bIDnew);
        }
    }
public function add ( $ data , $ c = false , $ a = false ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ u = new User ( ) ; if ( isset ( $ data [ 'uID' ] ) ) { $ uID = $ data [ 'uID' ] ; } else { $ uID = $ u -> getUserID ( ) ; } $ bName = '' ; if ( isset ( $ data [ 'bName' ] ) ) { $ bName = $ data [ 'bName' ] ; } $ btID = $ this -> btID ; $ dh = $ app -> make ( 'helper/date' ) ; $ bDate = $ dh -> getOverridableNow ( ) ; $ bIsActive = ( isset ( $ this -> btActiveWhenAdded ) && $ this -> btActiveWhenAdded == 1 ) ? 1 : 0 ; $ v = array ( $ bName , $ bDate , $ bDate , $ bIsActive , $ btID , $ uID ) ; $ q = "insert into Blocks (bName, bDateAdded, bDateModified, bIsActive, btID, uID) values (?, ?, ?, ?, ?, ?)" ; $ res = $ db -> executeQuery ( $ q , $ v ) ; // we get the block object for the block we just added if ( $ res ) { $ bIDnew = $ db -> lastInsertId ( ) ; $ nb = Block :: getByID ( $ bIDnew ) ; if ( is_object ( $ c ) ) { $ nb -> setBlockCollectionObject ( $ c ) ; } if ( is_object ( $ a ) ) { $ nb -> setBlockAreaObject ( $ a ) ; } $ class = $ this -> getBlockTypeClass ( ) ; $ bc = $ app -> build ( $ class , [ $ nb ] ) ; $ bc -> save ( $ data ) ; return Block :: getByID ( $ bIDnew ) ; } }
Adds a block to the system without adding it to a collection.
Passes page and area data along if it is available, however.

@param mixed            $data
@param bool|\Collection $c
@param bool|\Area       $a

@return bool|\Concrete\Core\Block\Block
Adds a block to the system without adding it to a collection . Passes page and area data along if it is available however .