Add a entity into the multiton array

@param Entity\Base
@param mixed If successful attachment the location of the new attachment

@return bool. Successful attachment?
509664
public function attach( Base $entity, &$restingPlace = null )
    {

        if( !$this->makeableSafetyCheck() ) {
            return null;
        }

        // check type
        if( !is_a( $entity, $this->entityClass ) ) {
            throw new EntityNotCompatibleWithRepositoryException( $entity, $this );
        }

        // At the moment something is new if it doesn't have a key set.
        // This is still a work in progress
        if( $key = $entity->keyGet( $entity ) ) {

            // check we've not got a collision already
            if( isset( $this->instancesPersisted[$key] ) ) {
                throw new \RuntimeException( "Repository entity merging not yet coded (but I'm not exactly sure why you need this). You've probably got a logic bug somewhere. What you are asking is, well, odd.");
            }

            $this->instancesPersisted[$key] = $entity;
            $restingPlace = self::PERSISTED;

        } else {

            // debugging check to find where something is being double attached
            if( false !== array_search( $entity, $this->instancesUnpersisted, true ) ) {
                d_pr( sane_debug_backtrace() );
                die();
            }

            $this->instancesUnpersisted[] = $entity;
            $restingPlace = self::UNPERSISTED;

        }

        return true;

    }
44374
function addDecorative(c) {
            if (c.$isDecorative !== true) {
                c.$$isDecorative = true;
            }
            this.$getSuper("insert").call(this, this.kids.length, null, c);
        }
677098
public static function add($parent = false)
    {
        $db = Database::connection();
        $treeNodeParentID = 0;
        $treeID = 0;
        $treeNodeDisplayOrder = 0;
        $inheritPermissionsFromTreeNodeID = 0;
        if (is_object($parent)) {
            $treeNodeParentID = $parent->getTreeNodeID();
            $treeID = $parent->getTreeID();
            $inheritPermissionsFromTreeNodeID = $parent->getTreeNodePermissionsNodeID();
            $treeNodeDisplayOrder = (int) $db->fetchColumn('select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?', [$treeNodeParentID]);
            $parent->updateDateModified();
        } else {
            $parent = null;
        }

        $treeNodeTypeHandle = uncamelcase(strrchr(get_called_class(), '\\'));

        $dateModified = Core::make('date')->toDB();
        $dateCreated = Core::make('date')->toDB();

        $type = TreeNodeType::getByHandle($treeNodeTypeHandle);
        $db->executeQuery(
            'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)',
            [
                $type->getTreeNodeTypeID(),
                $treeNodeParentID,
                $treeNodeDisplayOrder,
                $inheritPermissionsFromTreeNodeID,
                $dateModified,
                $dateCreated,
                $treeID,
            ]
        );
        $id = $db->lastInsertId();
        $node = self::getByID($id);

        if (!$inheritPermissionsFromTreeNodeID) {
            $node->setTreeNodePermissionsToOverride();
        }

        if ($parent !== null && $parent->childNodesLoaded) {
            $parent->childNodes[] = $node;
        }

        return $node;
    }
149092
public function attach($path_or_entity = null, $filename = null, $contentType = null) {
        if ($path_or_entity instanceof \Swift_Mime_MimeEntity) {
            $this->message->attach($path_or_entity);
        } else {

            $attachment = Mail::attachment($path_or_entity, $filename, $contentType);
            $this->message->attach($attachment);
        }

        return $this;
    }
548539
public function addChild(EntityInterface $child, $position = null, $returnChild = false)
    {
        if ($this->exists) {
            if (is_null($position)) {
                $position = $this->getNextAfterLastPosition($this->getKey());
            }

            $child->moveTo($position, $this);
        }

        return ($returnChild === true ? $child : $this);
    }
934574
private function fileEntitySelect($create = false, $status = null)
    {
        if (!$this->file && $this->contactClient) {
            $file = null;
            // Discern the next file entity to use.
            if (!$status) {
                $status = File::STATUS_QUEUEING;
            }
            if (!$this->test) {
                $file = $this->getFileRepository()->findOneBy(
                    ['contactClient' => $this->contactClient, 'status' => $status, 'test' => $this->test],
                    ['dateAdded' => 'desc']
                );
            }
            if (!$file && ($create || $this->test)) {
                // There isn't currently a file being built, let's create one.
                $file = new File();
                $file->setContactClient($this->contactClient);
                $file->setIsPublished(true);
                $file->setTest($this->test);
                if (!$this->test) {
                    $this->em->persist($file);
                }
            }

            if ($file) {
                $this->file = $file;
                $this->setLogs($this->file->getId(), 'fileId');
                $this->setLogs($this->file->getStatus(), 'fileStatus');
            }
        }

        if (!$this->file) {
            throw new ContactClientException(
                'Nothing queued up for this client yet.',
                0,
                null,
                Stat::TYPE_INVALID,
                false
            );
        }

        return $this;
    }
978474
public function addContact($databaseID, $updateIfFound, $columns, $contactListID = false, $sendAutoReply = false, $allowHTML = false, $createdFrom = 1, $visitorKey = '', $syncFields = []) {
        $data["Envelope"] = array(
            "Body" => array(
                "AddRecipient" => array(
                    "LIST_ID" => $databaseID,
                    "CREATED_FROM" => $createdFrom,
                    "SEND_AUTOREPLY"  => ($sendAutoReply ? 'true' : 'false'),
                    "UPDATE_IF_FOUND" => ($updateIfFound ? 'true' : 'false'),
                    "ALLOW_HTML" => ($allowHTML ? 'true' : 'false'),
                    "VISITOR_KEY" => $visitorKey,
                    "CONTACT_LISTS" => ($contactListID) ? array("CONTACT_LIST_ID" => $contactListID) : '',
                    "COLUMN" => array(),
                ),
            ),
        );
        foreach ($columns as $name => $value) {
            $data["Envelope"]["Body"]["AddRecipient"]["COLUMN"][] = array("NAME" => $name, "VALUE" => $value);
        }
        foreach ($syncFields as $name => $value) {
            $data["Envelope"]["Body"]["AddRecipient"]["SYNC_FIELDS"]["SYNC_FIELD"][] = array("NAME" => $name, "VALUE" => $value);
        }
        $response = $this->_request($data);
        $result = $response["Envelope"]["Body"]["RESULT"];
        if ($this->_isSuccess($result)) {
            if (isset($result['RecipientId']))
                return $result['RecipientId'];
            else {
                throw new \Exception('Recipient added but no recipient ID was returned from the server.');
            }
        } else {
            throw new \Exception("AddRecipient Error: ".$this->_getErrorFromResponse($response));
        }
    }
878918
public function addAttachment ($filePath = FALSE, $fileName = NULL, $fileData = FALSE, $mimeType = 'text/plain')
    {

        // If its an existing file

        if ($filePath !== FALSE)
        {

            // Check File Exists

            if (!file_exists ($filePath))
            {

                // Add error and return false

                new \Sonic\Message ('error', $filePath . ' doesnt exist!');
                return FALSE;

            }

            // Get MIME Type

            $objFinfo   = new finfo;

            if (!$mimeType = $objFinfo->file ($filePath, FILEINFO_MIME))
            {

                // Add error and return false

                new \Sonic\Message ('error', 'Cannot get MIME type!');
                return FALSE;

            }

            // Get File Data

            if (!$fileData = @file_get_contents ($filePath))
            {

                // Add error and return false

                new \Sonic\Message ('error', 'Cannot get attachment data!');
                return FALSE;

            }

        }
        else if (!$fileData || !$fileName)
        {

            // Add error and return false

            new \Sonic\Message ('error', 'Invalid Attachment!');
            return FALSE;

        }

        // Set attachments boolean

        $this->_attachmentsSet	= TRUE;

        // Add Attachment

        $this->_attachments[]	= array (
            'name'		=> $fileName,
            'data'		=> $fileData,
            'type'		=> $mimeType
        );

        // Return TRUE

        return TRUE;

    }
754698
public function add()
    {
        $entity = $this->Dblists->newEntity();
        if ($this->request->is('post')) {
            $entity = $this->Dblists->patchEntity($entity, (array)$this->request->getData());
            if ($this->Dblists->save($entity)) {
                $this->Flash->success('The database list has been saved.');

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error('The database list could not be saved. Please, try again.');
        }

        $this->set(compact('entity'));
        $this->set('_serialize', ['entity']);
    }
117394
public function add_to_media_library()
    {
        if ($this->upload_path === false) {
            return false;
        }

        $attachment = [
            'guid' => $this->upload_url,
            'post_mime_type' => $this->upload_type,
            'post_title' => \pathinfo($this->upload_path, PATHINFO_FILENAME),
            'post_content' => '',
            'post_status' => 'inherit',
        ];

        // Insert the attachment.
        $attach_id = \wp_insert_attachment($attachment);

        if ($attach_id == 0 || $attach_id instanceof \WP_Error) {
            return false;
        }

        // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
        require_once(ABSPATH . 'wp-admin/includes/image.php');

        // Generate the meta for the attachment.
        $attach_data = \wp_generate_attachment_metadata($attach_id, $this->upload_path);

        // Update attachment meta.
        \wp_update_attachment_metadata($attach_id, $attach_data);
        \update_attached_file($attach_id, $this->upload_path);

        $this->attachment_id = $attach_id;

        return true;
    }
742943
function addChild(&$child)
    {
        /* Make sure this is a Log instance. */
        if (!is_a($child, 'Log')) {
            return false;
        }

        $this->_children[$child->_id] = $child;

        return true;
    }
655548
public static function addAttachmentFromFile($object, $filename)
    {
        return self::addAttachment($object, basename($filename),
                file_get_contents($filename), mime_content_type($filename));
    }
339384
public function add($entity, $quantity)
    {
        if ($this->itemExists($entity)) {
            $cartItemIndex = $this->items->search($this->cartItemsCheck($entity));

            return $this->incrementQuantityAt($cartItemIndex, $quantity);
        }

        $this->items->push(CartItem::createFrom($entity, $quantity));

        event(new CartItemAdded($entity));

        return $this->cartUpdates($isNewItem = true);
    }
768011
public function add(array $file = null, $force = false)
    {
        $args   = array();
        if ($force) {
            $args[]  = '--force';
        }
        if ($file !== null) {
            $args[] = '--';
            $args   = array_merge($args, array_map(array($this, 'translatePathspec'), $this->resolveLocalPath($file)));
        } else {
            $args[] = '--all';
        }

        /** @var $result CallResult */
        $result = $this->getGit()->{'add'}($this->getRepositoryPath(), $args);
        $result->assertSuccess(sprintf('Cannot add "%s" to "%s"',
            ($file !== null) ? implode(', ', $file) : '*', $this->getRepositoryPath()
        ));
    }
1132568
public function add_file( $file, array $atts = array() ) {

		$parent = $this->get_file( dirname( $file ) );
		$filename = basename( $file );

		if ( false === $parent || true === isset( $parent->contents->$filename ) ) {
			return false;
		}

		$parent->contents->$filename = $this->get_default_atts( $atts );

		return true;
	}
1097748
public function entity($url, EntityInterface $entity, $override = false)
    {
        if (!($path = parse_url($url, PHP_URL_PATH))) {
            throw new \InvalidArgumentException('It is invalid URL: '.$url);
        }
        $entity->setFilename(pathinfo($path, PATHINFO_BASENAME));
        $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename();

        if ($entity instanceof ImageInterface) {
            return $this->image($url, $target, $override);
        } else {
            return $this->download($url, $target, $override);
        }
    }
325620
function is_link($new = null, $return_entity = false)
    {
        if (isset($new) && ($this->_attributes['is_link'] != $new)){
            $this->change('is_link', (bool)$new);
        }
        if ($return_entity){
            if (!isset($this->_link)){
                if (empty($this->_attributes['is_link'])){
                    $this->_link = false;
                }else
                if (($this->_link = $this->proto(null, true))){
                    if ($p = $this->_link->is_link(null, true)) $this->_link = $p;
                }
            }
            return $this->_link;
        }
        return $this->_attributes['is_link'];
    }