Get last version for a post

@param integer $id AsfDocumentBundle:Page  ID
170640
public function getLastVersion($post_id)
	{
		$qb = $this->createQueryBuilder('p');
		
		$qb->where('p.original=:post_id')
			->orderBy('p.createdAt', 'DESC')
			->setParameter(':post_id', $post_id);
		
		$result = $qb->getQuery()->setMaxResults(1)->getResult(Query::HYDRATE_OBJECT);
		
		if ( is_null($result) ) {
			$qb2 = $this->createQueryBuilder('p');
			$qb2->where('p.id=:post_id')->setParameter(':post_id', $post_id);
			
			$result = $qb->getQuery()->getResult(Query::HYDRATE_OBJECT);
		}
		
		return $result;
	}
1192196
public function get($id)
    {
        $file_name = $this->getFileName($id);

        if (!is_file($file_name) || !is_readable($file_name)) {
            return false;
        }

        $lines    = file($file_name);
        $lifetime = array_shift($lines);
        $lifetime = (int) trim($lifetime);

        if ($lifetime !== 0 && $lifetime < time()) {
            @unlink($file_name);
            return false;
        }
        $serialized = join('', $lines);
        $data       = unserialize($serialized);
        return $data;
    }
1350911
protected function determinePostType( $id ) {

		$chapters = getset( '_POST', 'chapters' );
		$supported_types = apply_filters( 'pb_import_custom_post_types', [ 'front-matter', 'chapter', 'part', 'back-matter', 'metadata', 'glossary' ] );
		$default = 'chapter';

		if ( ! is_array( $chapters ) ) {
			return $default;
		}

		if ( ! isset( $chapters[ $id ] ) && ! isset( $chapters[ $id ]['type'] ) ) {
			return $default;
		}

		if ( ! in_array( $chapters[ $id ]['type'], $supported_types, true ) ) {
			return $default;
		}

		return $chapters[ $id ]['type'];
	}
127360
static function getBookStructure( $id = null ) {

		if ( ! empty( $id ) && is_int( $id ) ) {
			$blog_id = $id;
			switch_to_blog( $id );
		} else {
			global $blog_id;
		}

		// -----------------------------------------------------------------------------
		// Is cached?
		// -----------------------------------------------------------------------------

		$cache_id = "book-str-$blog_id";
		if ( static::useCache() ) {
			$book_structure = wp_cache_get( $cache_id, 'pb' );
			if ( $book_structure ) {
				return $book_structure;
			}
		}

		// -----------------------------------------------------------------------------
		// Query our custom post types, keep minimal data in $book_structure
		// -----------------------------------------------------------------------------

		$post_ids_to_export = static::getPostsIdsToExport();

		$custom_types = [
			'front-matter',
			'part',
			'chapter',
			'back-matter',
		];

		$book_structure = [];
		foreach ( $custom_types as $type ) {
			$book_structure[ $type ] = [];
		}

		$q = new \WP_Query();
		$results = $q->query(
			[
				'post_type' => $custom_types,
				'posts_per_page' => -1, // @codingStandardsIgnoreLine
				'post_status' => 'any',
				'orderby' => 'menu_order',
				'order' => 'ASC',
				'no_found_rows' => true,
				'cache_results' => true,
			]
		);

		/** @var \WP_Post $post */
		foreach ( $results as $post ) {
			// Fix empty slugs
			$post_name = empty( trim( $post->post_name ) ) ? uniqid( 'slug-' ) : $post->post_name;

			$book_structure[ $post->post_type ][] = [
				'ID' => $post->ID,
				'post_title' => $post->post_title,
				'post_name' => $post_name,
				'post_author' => (int) $post->post_author,
				'comment_count' => (int) $post->comment_count,
				'menu_order' => $post->menu_order,
				'post_status' => $post->post_status,
				'post_parent' => $post->post_parent,
				'export' => ( isset( $post_ids_to_export[ $post->ID ] ) && 'on' === $post_ids_to_export[ $post->ID ] ) ? true : false,
				'has_post_content' => ! empty( trim( $post->post_content ) ),
				'word_count' => \Pressbooks\Utility\word_count( $post->post_content ),
			];
		}

		// -----------------------------------------------------------------------------
		// Add Chapters to Parts
		// -----------------------------------------------------------------------------

		foreach ( $book_structure['part'] as $i => $part ) {
			// There's no `pb_export` for parts. We instead have `pb_part_invisible` and it doesn't mean the same thing. Force to true.
			$book_structure['part'][ $i ]['export'] = true;
			$book_structure['part'][ $i ]['chapters'] = [];
		}

		foreach ( $book_structure['chapter'] as $i => $chapter ) {
			foreach ( $book_structure['part'] as $j => $part ) {
				if ( $part['ID'] === $chapter['post_parent'] ) {
					$book_structure['part'][ $j ]['chapters'][] = $chapter;
					unset( $book_structure['chapter'][ $i ] );
					continue 2;
				}
			}
		}

		/* Track unexpected orphans, unset() chapter from $book_structure and $types */

		if ( count( $book_structure['chapter'] ) ) {
			$book_structure['__orphans'] = $book_structure['chapter'];
		}

		unset( $book_structure['chapter'] );
		$custom_types = array_diff( $custom_types, [ 'chapter' ] );

		// -----------------------------------------------------------------------------
		// Create __order arrays, remove post_parent
		// -----------------------------------------------------------------------------

		$book_structure['__order'] = [];
		foreach ( $custom_types as $type ) {
			foreach ( $book_structure[ $type ] as $i => $struct ) {
				unset( $book_structure[ $type ][ $i ]['post_parent'] );
				if ( 'part' !== $type ) {
					$book_structure['__order'][ $struct['ID'] ] = [
						'export' => $struct['export'],
						'post_status' => $struct['post_status'],
						'post_name' => $struct['post_name'],
						'post_type' => $type,
					];
				} else {
					if ( $struct['has_post_content'] && get_post_meta( $struct['ID'], 'pb_part_invisible', true ) !== 'on' ) {
						$book_structure['__order'][ $struct['ID'] ] = [
							'export' => $struct['export'],
							'post_status' => $struct['post_status'],
							'post_name' => $struct['post_name'],
							'post_type' => 'part',
						];
					}
					foreach ( $struct['chapters'] as $j => $chapter ) {
						unset( $book_structure[ $type ][ $i ]['chapters'][ $j ]['post_parent'] );
						if ( $struct['has_post_content'] && get_post_meta( $struct['ID'], 'pb_part_invisible', true ) !== 'on' ) {
							$book_structure['__order'][ $struct['ID'] ] = [
								'export' => $struct['export'],
								'post_status' => $struct['post_status'],
								'post_name' => $struct['post_name'],
								'post_type' => 'part',
							];
						}
						$book_structure['__order'][ $chapter['ID'] ] = [
							'export' => $chapter['export'],
							'post_status' => $chapter['post_status'],
							'post_name' => $chapter['post_name'],
							'post_type' => 'chapter',
						];
					}
				}
			}
		}
		static::$__order = $book_structure['__order'];

		// -----------------------------------------------------------------------------
		// Cache & Return
		// -----------------------------------------------------------------------------

		if ( static::useCache() ) {
			wp_cache_set( $cache_id, $book_structure, 'pb', DAY_IN_SECONDS );
		}

		if ( ! empty( $id ) && is_int( $id ) ) {
			restore_current_blog();
		}

		return $book_structure;
	}
694436
protected function __apiUpdate (string $id)
    {
        $record = HCResources::findOrFail ($id);

        $data = $this->getInputData ();

        $record->update (array_get ($data, 'record'));

        return $this->apiShow ($record->id);
    }
150587
public function getPage($id)
    {
        return isset($this->pages[$id])?$this->pages[$id]:null;
    }
546611
public function findDocumentById($id)
    {
        $response = $this->request('GET', '/' . $id);
        if ($response->getStatusCode() !== 200) {
            return null;
        }

        return $this->documentFactory->createFromResponse($this, $id, $response);
    }
128018
def get_last_content(request, page_id):
    """"""
    content_type = request.GET.get('content_type')
    language_id = request.GET.get('language_id')
    page = get_object_or_404(Page, pk=page_id)
    placeholders = get_placeholders(page.get_template())
    _template = template.loader.get_template(page.get_template())
    for placeholder in placeholders:
        if placeholder.name == content_type:
            context = RequestContext(request, {
                'current_page': page,
                'lang': language_id
            })
            with context.bind_template(_template.template):
                content = placeholder.render(context)
                return HttpResponse(content)
    raise Http404
434530
public function actionView($id)
    {
        $record = $this->findRecord($id);
        if ($record->lastExec && $record->lastExec->isFailed()) {
            return $this->redirect(['view-attempts', 'id' => $record->id]);
        }
        return $this->redirect(['view-details', 'id' => $record->id]);
    }
138591
public PluginRelease getLastPluginRelease(String id) {
        PluginInfo pluginInfo = getPluginsMap().get(id);
        if (pluginInfo == null) {
            return null;
        }

        if (!lastPluginRelease.containsKey(id)) {
            for (PluginRelease release : pluginInfo.releases) {
                if (systemVersion.equals("0.0.0") || versionManager.checkVersionConstraint(systemVersion, release.requires)) {
                    if (lastPluginRelease.get(id) == null) {
                        lastPluginRelease.put(id, release);
                    } else if (versionManager.compareVersions(release.version, lastPluginRelease.get(id).version) > 0) {
                        lastPluginRelease.put(id, release);
                    }
                }
            }
        }

        return lastPluginRelease.get(id);
    }
685226
public function get($id)
    {
        return $this->_sendPayload(
            $this->_getService($this->_pageServiceKey)->getTemplateLayout($id)
        );
    }
886024
public function get($id)
    {
        return $this->_sendPayload(
            $this->_getService($this->_pageServiceKey)->getPageLayout($id)
        );
    }
1138313
public function getEdit($id = null)
    {
        $group = Sentinel::getRoleRepository()->find($id);

        // Get the group's information
        if($group == null)
        {
            // Prepare the error message
            $error = Lang::get('base.groups.not_found');

            // Redirect to the post management page
            return Redirect::route('groups')->with('error', $error);
        }

        $groups = null;

        $groups2 = Sentinel::getRoleRepository()->all(['id', 'name']);

        foreach ($groups2 as $g)
            $groups[$g->id] = $g->name;

        // Show the page
        return View('admin.groups.edit', compact('group', 'groups'));
    }
195685
public function rawPost($id) {
		$item = $this->dataService->byId('MicroPost', $id);
		if ($item->checkPerm('Write')) {
			return $item;
		}
	}
10814
def get_last(postid, limit=10):
        '''
        
        '''
        recs = TabPostHist.select().where(
            TabPostHist.post_id == postid
        ).order_by(TabPostHist.time_update.desc()).limit(limit)
        if recs.count():
            return recs.get()
        return None
604313
public function getPostEditPost($id)
    {
        $form = new EditPostForm($this->di, $id);
        $form->check();

        $views = [
            ["comment/default-form", ["form" => $form->getHTML()], "main"]
        ];

        $this->di->get("pageRenderComment")->renderPage([
            "views" => $views,
            "title" => "Edit post | $id"
        ]);
    }
455047
public function get($id)
    {
        $entry = $this->readFile($id);
        if ($entry != false && $this->isTtlMode()) {
            $entry = (is_null($entry[static::ENTRY_EXPIRATION]) || $entry[static::ENTRY_EXPIRATION] > $this->getTime())
                ? $entry[static::ENTRY_VALUE]
                : false
            ;
        }
        return $entry;
    }