Do the actual registration with WordPress.

@since 0.1.0

@param string     $cpt            Slug of the custom content.
@param Collection $argsCollection Collection of arguments.
541725
protected function doRegistration( $cpt, Collection $argsCollection ) {
		/** @var ArgumentCollection $argsCollection */
		register_taxonomy(
			$cpt,
			$argsCollection->get( Argument::POST_TYPES ),
			$argsCollection->toArray()
		);
	}
821062
public function postPersist(LifecycleEventArgs $args)
    {
        if ($args->getObject() instanceof BlockInterface && !$args->getObject() instanceof DocumentBlock) {
            $this->getService($args)->postPersist($args->getObject());
        }
    }
63297
public function getPostsForArgs($args, $postClass = '\TimberPost', $collection = false)
    {
        return $this->getTimberBridge()->getPosts($args, $postClass, $collection);
    }
574143
public function add($typeName, $args)
	{
		// set default
		$args = array_merge_recursive(array(
			'public' => true,
			'supports' => array(
				'title',
				'editor',
				'thumbnail',
				'revisions',
			),
			'has_archive' => true,
		), $args);

		$this->posttypes[$typeName] = $args;

		return true;
	}
16949
public function registerCollector(CollectorInterface $collector)
    {
        if ($collector instanceof StartCollectorInterface) {
            $this->collectors['initial'][$collector->getPath()] = $collector;
        } elseif ($collector instanceof FinalCollectorInterface) {
            $this->collectors['final'][$collector->getPath()] = $collector;
        } elseif ($collector instanceof StreamCollectorInterface) {
            $this->collectors['stream'][$collector->getPath()] = $collector;
        } else {
            throw new \RuntimeException('Collector must be implementation of StartCollectorInterface, '
                . 'FinalCollectorInterface or StreamCollectorInterface Path=' . $collector->getPath());
        }
    }
800237
public function register( $args = [ ] ) {
		foreach ( $this->getConfigKeys() as $slug ) {

			if ( $this->isReservedTerm( $slug ) ) {
				throw new ReservedTermException( $slug );
			}

			if ( static::DEFAULTS === $slug ) {
				continue;
			}

			$argsCollection = $this->prepareArguments( $slug, (array) $args );
			$this->doRegistration( $slug, $argsCollection );
		}
	}
875352
protected function configureRoutes(RouteCollection $collection)
    {
        parent::configureRoutes($collection);

        $collection->add('moveUp', $this->getRouterIdParameter() . '/move-up');
        $collection->add('moveDown', $this->getRouterIdParameter() . '/move-down');
    }
585002
private function add($field, $args)
    {
        $this->initializeDoctrine();

        $property = $this->cm->getProperty($field);

        if (! $property) {
            throw new BadMethodCallException("no field with name '" . $field . "' exists on '" . $this->cm->getClassName() . "'");
        }

        if (! ($property instanceof ToManyAssociationMetadata)) {
            throw new BadMethodCallException('There is no method add' . $field . '() on ' . $this->cm->getClassName());
        }

        $targetClassName = $property->getTargetEntity();

        if (! ($args[0] instanceof $targetClassName)) {
            throw new InvalidArgumentException("Expected persistent object of type '" . $targetClassName . "'");
        }

        if (! ($this->{$field} instanceof Collection)) {
            $this->{$field} = new ArrayCollection($this->{$field} ?: []);
        }

        $this->{$field}->add($args[0]);

        $this->completeOwningSide($property, $args[0]);

        return $this;
    }
1127889
public function create($args)
    {
        $meta_args = [];
        $tax_args  = [];

        /*
         * Array of taxonomy terms keyed by their taxonomy name, which WP-CLI can't handle.
         *
         * Values may be delimited by a comma.
         *
         * See https://github.com/wp-cli/entity-command/issues/44#issuecomment-325957179
         */
        if (isset($args['tax_input'])) {
            $tax_args = $args['tax_input'];
            unset($args['tax_input']);
        }

        /*
         * Array of post meta values keyed by their post meta key, which WP-CLI can't handle.
         *
         * See https://github.com/wp-cli/entity-command/issues/44#issuecomment-325957179
         */
        if (isset($args['meta_input'])) {
            $meta_args = $args['meta_input'];
            unset($args['meta_input']);
        }

        $wpcli_args = buildCLIArgs(
            array(
                'ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title',
                'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name',
                'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type',
                'guid', 'post_category', 'page_template',
            ),
            $args
        );

        array_unshift($wpcli_args, '--porcelain');
        $post_id = (int) $this->drivers->getDriver()->wpcli('post', 'create', $wpcli_args)['stdout'];

        // Apply taxonomy values.
        if ($tax_args) {
            foreach ($tax_args as $taxonomy => $terms) {
                $split_terms = str_getcsv($terms);

                foreach ($split_terms as $split_term) {
                    $args = [
                        $post_id,
                        $taxonomy,
                        escapeshellarg($split_term),
                    ];

                    $this->drivers->getDriver()->wpcli('post', 'term add', $args);
                }
            }
        }

        // Apply post meta values.
        if ($meta_args) {
            foreach ($meta_args as $meta_key => $meta_value) {
                $args = [
                    $post_id,
                    $meta_key,
                    escapeshellarg($meta_value),
                ];

                $this->drivers->getDriver()->wpcli('post', 'meta update', $args)['stdout'];
            }
        }

        return $this->get($post_id);
    }
695836
public function register($filename, $args, $pkg = false)
    {
        parent::register($filename, $args, $pkg);
        if (!empty($args['media'])) {
            $this->setAssetMedia($args['media']);
        }
    }
950253
public function writeArguments(PhpArgumentCollection $arguments)
    {
        try {
            $argsCount = count($arguments);

            for ($i = 0; $i < $argsCount; $i++) {

                $this->writeArgument($arguments[$i]);

                if ($i < $argsCount - 1) {
                    $this->writeComma();
                }
            }
        } catch (Exception $e) {
            $msg = "An error occured while writing a sequence of arguments.";
            throw new StreamAccessException($msg, $this, 0, $e);
        }
    }
557077
public static function add(&$set, $args)
    {
        self::assertArgsNumber(1, $args);

        $value = $args[0];

        foreach ($set as $item) {
            if ($item === $value) {
                return;
            }
        }

        $set[] = $value;
    }
1288872
protected function registerMessages( $cpt, ArgumentCollection $args ) {
		$method_name = "messages_for_${cpt}";

		$this->$method_name = function ( $messages ) use ( $cpt, $args ) {

			$args->prepareMessages();

			$messages[ $cpt ] = $args->get( Argument::MESSAGES );

			if ( $this->isQueryable( $cpt ) ) {

				$permalink = $this->getPermalink();

				foreach ( $this->getMessagesWithViewLink() as $key ) {
					$messages[ $cpt ][ $key ] .= $this->getViewLink( $permalink,
						$args );
				}

				foreach ( $this->getMessagesWithPreviewLink() as $key ) {
					$messages[ $cpt ][ $key ] .= $this->getPreviewLink( $permalink,
						$args );
				}
			}

			return $messages;
		};

		add_filter( 'post_updated_messages', [ $this, $method_name ] );
	}
423319
public function addCollectionAlias($c)
    {
        $db = Database::connection();
        // the passed collection is the parent collection
        $cParentID = $c->getCollectionID();

        $u = new User();
        $uID = $u->getUserID();

        $handle = $this->getCollectionHandle();
        $cDisplayOrder = $c->getNextSubPageDisplayOrder();

        $_cParentID = $c->getCollectionID();
        $q = 'select PagePaths.cPath from PagePaths where cID = ?';
        $v = array($_cParentID);
        if ($_cParentID > 1) {
            $q .=  ' and ppIsCanonical = ?';
            $v[] = 1;
        }
        $cPath = $db->fetchColumn($q, $v);

        $data = array(
            'handle' => $this->getCollectionHandle(),
            'name' => $this->getCollectionName(),
        );
        $cobj = parent::addCollection($data);
        $newCID = $cobj->getCollectionID();

        $v = array($newCID, $cParentID, $uID, $this->getCollectionID(), $cDisplayOrder);
        $q = "insert into Pages (cID, cParentID, uID, cPointerID, cDisplayOrder) values (?, ?, ?, ?, ?)";
        $r = $db->prepare($q);

        $r->execute($v);

        PageStatistics::incrementParents($newCID);

        $q2 = 'insert into PagePaths (cID, cPath, ppIsCanonical, ppGeneratedFromURLSlugs) values (?, ?, ?, ?)';
        $v2 = array($newCID, $cPath.'/'.$handle, 1, 1);
        $db->executeQuery($q2, $v2);

        return $newCID;
    }
699633
public static function add($cPath, $pkg = null) {
		// if we get to this point, we create a special collection
		// without a specific type. This collection has a special cFilename that
		// points to the passed node
		$db = Loader::db();
		$txt = Loader::helper('text');
		Loader::helper('concrete/ui')->clearInterfaceItemsCache();

		// trim off a leading / if there is one
		$cPath = trim($cPath, '/');

		// now we grab the parent collection, if there is a static one.

		$pages = explode('/', $cPath);

		// instantiate the home collection so we have someplace to add these to
		$parent = CorePage::getByID(1);

		// now we iterate through the pages  to ensure that they exist in the system before adding the new guy

		$pathPrefix = '';

		for ($i = 0; $i < count($pages); $i++) {
			$currentPath = $pathPrefix . $pages[$i];

			$pathToFile = static::getPathToNode($currentPath, $pkg);

			// check to see if a page at this point in the tree exists
			$c = CorePage::getByPath("/" . $currentPath);
			if ($c->isError() && $c->getError() == COLLECTION_NOT_FOUND) {
				// create the page at that point in the tree

				$data = array();
				$data['handle'] = $pages[$i];
				$data['name'] = $txt->unhandle($data['handle']);
				$data['filename'] = $pathToFile;
				$data['uID'] = USER_SUPER_ID;
				if ($pkg != null) {
					$data['pkgID'] = $pkg->getPackageID();
				}

				$newC = $parent->addStatic($data);
				$parent = $newC;


			} else {
				$parent = $c;
			}

			$pathPrefix = $currentPath . '/';
		}
		$env = Environment::get();
		$env->clearOverrideCache();
		return $parent;

	}
974834
public function publishCollection(CollectionInterface $collection, callable $callback = null)
    {
        $storage = $collection->getStorage();
        if ($storage instanceof PackageStorage) {
            foreach ($storage->getPublicResourcePaths() as $packageKey => $path) {
                $this->publishDirectory($path, $packageKey);
            }
        } else {
            parent::publishCollection($collection, $callback);
        }
    }
220385
public function register_post_type_rules( $post_type, $args ) {

		/**
		 * WP_Rewrite.
		 *
		 * @var WP_Rewrite $wp_rewrite
		 */
		global $wp_rewrite;

		if ( $args->_builtin ) {
			return;
		}

		if ( false === $args->rewrite ) {
			return;
		}

		if ( ! in_array( $post_type, CPTP_Util::get_post_types(), true ) ) {
			return;
		}

		$permalink = CPTP_Util::get_permalink_structure( $post_type );

		if ( ! $permalink ) {
			$permalink = CPTP_DEFAULT_PERMALINK;
		}

		$permalink = '%' . $post_type . '_slug%' . $permalink;
		$permalink = str_replace( '%postname%', '%' . $post_type . '%', $permalink );

		add_rewrite_tag( '%' . $post_type . '_slug%', '(' . $args->rewrite['slug'] . ')', 'post_type=' . $post_type . '&slug=' );

		$taxonomies = CPTP_Util::get_taxonomies( true );
		foreach ( $taxonomies as $taxonomy => $objects ) :
			$wp_rewrite->add_rewrite_tag( "%$taxonomy%", '(.+?)', "$taxonomy=" );
		endforeach;

		$rewrite_args = $args->rewrite;
		if ( ! is_array( $rewrite_args ) ) {
			$rewrite_args = array(
				'with_front' => $args->rewrite,
			);
		}

		$slug = $args->rewrite['slug'];
		if ( $args->has_archive ) {
			if ( is_string( $args->has_archive ) ) {
				$slug = $args->has_archive;
			};

			if ( $args->rewrite['with_front'] ) {
				$slug = substr( $wp_rewrite->front, 1 ) . $slug;
			}

			if ( CPTP_Util::get_post_type_date_archive_support( $post_type ) ) {
				$date_front = CPTP_Util::get_date_front( $post_type );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/([0-9]{1,2})/?$', 'index.php?year=$matches[1]&monthnum=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&feed=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$', 'index.php?year=$matches[1]&feed=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/page/?([0-9]{1,})/?$', 'index.php?year=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . $date_front . '/([0-9]{4})/?$', 'index.php?year=$matches[1]&post_type=' . $post_type, 'top' );
			}

			if ( CPTP_Util::get_post_type_author_archive_support( $post_type ) ) {

				add_rewrite_rule( $slug . '/author/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?author_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . '/author/([^/]+)/?$', 'index.php?author_name=$matches[1]&post_type=' . $post_type, 'top' );
			}

			if ( in_array( 'category', $args->taxonomies, true ) ) {

				$category_base = get_option( 'category_base', 'category' );

				add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/page/?([0-9]{1,})/?$', 'index.php?category_name=$matches[1]&paged=$matches[2]&post_type=' . $post_type, 'top' );
				add_rewrite_rule( $slug . '/' . $category_base . '/([^/]+)/?$', 'index.php?category_name=$matches[1]&post_type=' . $post_type, 'top' );

			}

			do_action( 'CPTP_registered_' . $post_type . '_rules', $args, $slug );
		}

		$rewrite_args['walk_dirs'] = false;
		add_permastruct( $post_type, $permalink, $rewrite_args );

	}