Dropsolid Drupal 10 Upkeep and Assist Service James & Jenny, our toolbox for sooner development

09 Nov James & Jenny, our toolbox for sooner development Nick Vanpraet Tech 8 Remember, it is a longread with in depth worth. Solely learn this in case you are able to uncover our Dropsolid group’s thrilling dev instrument and platform secrets and techniques!   James & Jenny may sound extra like a comedy double act or Drupal Development Company protagonists of an long-forgotten story, however they’re in truth very a lot alive and kicking. They’re Drupal Development Company names we gave to Drupal Development Company platforms that we developed in-house to spin up environments sooner and get work carried out extra effectively. How? Learn on!   In follow Each time we need to spin up a brand new server, begin a brand new mission and even create a brand new testing atmosphere, we nonetheless depend on our infrastructure group. Some time in the past we managed to automate our construct pipeline with some good configuration of Jenkins, an open supply piece of software program. Mixed with a permission system, we’re already capable of let technical shoppers or consultants take part in Drupal Development Company development strategy of a web site by triggering a construct of an atmosphere. We determined to name this home-coded piece of software program James, our in-house Cloud Butler. Nevertheless, this UI was very cluttered and it was simple to interrupt Drupal Development Company chain. Upkeep-wise, it wasn’t Drupal Development Company friendliest system both. James 0.1 was very useful, however wanted sprucing. Behind Drupal Development Company scenes we began constructing a correct platform that was designed to supersede this current system and take over Drupal Development Company creation of recent servers, tasks and environments by including a layer on high of this – a layer that would discuss to Jenkins and would be capable of execute Ansible playbooks via a managed system through RabbitMQ. You could possibly see this as James 0.2. This model of James solely has one account and isn’t constructed with a terrific many permissions in thoughts. Its objective may be very easy Drupal 10 Upkeep and Assist Service get stuff carried out. This implies we nonetheless can’t let shoppers or inside workers create new environments on James immediately or arrange new tasks. However we’d actually wish to. That is why we’re at present additionally investing closely in Drupal Development Company additional development of Jenny, Drupal Development Company site-spinning machine. Jenny’s intention is to be a user-friendly layer on high of James and it consists of of two elements Drupal 10 Upkeep and Assist Service a loosely decoupled Angular software consuming a 8 backend uncovered via a REST API, which in flip talks to James via its REST API. As a result of Jenny makes certain solely calls which can be allowed undergo to James, James can keep centered on performance with out having so as to add a ton of logic to ensure Drupal Development Company request is legitimate. If Drupal Development Company one that needs that new atmosphere isn’t allowed to request one, Jenny received’t ask James to set it up in Drupal Development Company first place.   The way it works   A Jenny person will be capable of create a brand new group, and inside that group create new tasks or clone current ones. These tasks will be housed on our servers or on exterior internet hosting (with or with out VPN, Firewalls or the rest that’s required). They’ll be capable of create new environments, archive total tasks or only a single atmosphere, construct, again up, restore, sync throughout environments, log in to an atmosphere’s web site, and so on. It would even include details about Drupal Development Company well being of Drupal Development Company servers and likewise present analytics about Drupal Development Company websites themselves. Now, as a result of single-person organisations are fairly non-existent, that person will be capable of add different customers to their group and provides them totally different permissions based mostly on their precise function inside Drupal Development Company company. A marketeer doesn’t must know Drupal Development Company well being of a feature-testing atmosphere, and a developer has little use in seeing analytics about Drupal Development Company stay atmosphere. Drupal Development purpose of this permission system is to supply Drupal Development Company shopper sufficient choices that they’ll prohibit a developer from archiving stay however permit them to create a brand new testing atmosphere and get all wanted data and entry for that atmosphere. On a sidenote Drupal 10 Upkeep and Assist Service these aren’t commonplace permissions, as a result of these are for members inside a company, and a single person will be part of many organizations and have totally different permissions for each.   Finish-to-end However all these layers have to have the ability to discuss to one another earlier than any of that may occur. JennyA(ngular) has to speak to JennyB(ackend), JennyB then has to ensure Drupal Development Company request is legitimate and discuss to James. And no matter data James returns, needs to be checked by JennyB, saved in Drupal Development Company database if wanted, after which remodeled right into a message that JennyA can do one thing with. To verify we will really pull this off, we created Drupal Development Company following check case Drupal 10 Upkeep and Assist ServiceHow will we set off a construct of an atmosphere in Jenkins from JennyA, and the way will we present Drupal Development Company construct log from Jenkins in JennyA? JennyA Drupal 10 Upkeep and Assist Service construct Drupal Development Company web page, get mission and atmosphere data from JennyB, create a button and ship request to API. How this course of occurs precisely, can be defined in a special submit. JennyB For this REST useful resource we’d like two entities Drupal 10 Upkeep and Assist Service Challenge and Surroundings. We create some new permissions (outlined as choices in an OrgRole entity) for our Surroundings entity sort Drupal 10 Upkeep and Assist Service Create atmosphere Edit atmosphere Delete atmosphere Archive atmosphere View atmosphere View archived atmosphere Construct atmosphere Subsequent to this, we construct a customized EntityAccessControlHandler that checks these customized permissions. An AccessControlHandler will need to have two strategies Drupal 10 Upkeep and Assist Service checkAccess() and checkCreateAccess(). In each we need to be certain ’s regular permissions (which for this entity we cut back to easily ‘handle mission atmosphere entities’) nonetheless rule supreme, so superadmins can debug every part. Which is why each entry checks begin with a standard, bog-standard $account->hasPermission() examine. if ($account->hasPermission(‘administer mission atmosphere entities’)) { return AccessResult Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist Serviceallowed(); } However then we’ve so as to add some additional logic to ensure Drupal Development Company person is allowed to do no matter it’s they’re trying to do. For that we seize that person’s at present lively Membership. A Membership is a straightforward entity that mixes a person, a company, and an OrgRole entity which says what permissions Drupal Development Company person has inside that group. For non-Create entry we first examine if this person is even part of Drupal Development Company identical group as Drupal Development Company entity they’re making an attempt to save lots of. // Get Drupal Development Company group for this mission atmosphere $group = $entity->getProject()->getOrganization(); // Test that Drupal Development Company lively membership and Drupal Development Company connected group match $accessResult = Membership Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicecheckIfAccountIsPartOfCorrectOrganization($group, $account); if ($accessResult->isForbidden()) { return $accessResult; } For brevity’s sake, I received’t clarify how precisely checkIfAccountIsPartOfCorrectOrganization does its checks. But it surely returns an AccessResultInterface object and does precisely what it says on Drupal Development Company tin. It additionally features a cause for forbidding entry, so we will extra simply debug issues. You may simply add a string to Drupal Development Company creation of an AccessResult or use $accessResult->setReason() and you may then seize it utilizing $accessResult->getReason(). Take notice Drupal 10 Upkeep and Assist Service solely forbidden and impartial implement that technique. Be sure that Drupal Development Company outcome implements Drupal Development Company AccessResultReasonInterface earlier than calling both technique. if ($accessResult instanceof AccessResultReasonInterface) { $accessResult->getReason(); } We use this extensively with our unit testing, so we all know precisely why one thing fails. Assuming our check passes, we will lastly examine if this person has Drupal Development Company right permissions. $entityOrganizationMembership = Consumer Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist Serviceload($account->id())->getActiveMembership(); change ($operation) { case ‘view’ Drupal 10 Upkeep and Assist Service if (!$entity->isActive()) { return $this->allowedIf($entityOrganizationMembership->hasPermission(‘view archived mission atmosphere’), ‘member doesn’t have “view archived mission atmosphere” permission’); } return $this->allowedIf($entityOrganizationMembership->hasPermission(‘view mission atmosphere’), ‘member doesn’t have “view mission atmosphere” permission’); case ‘replace’ Drupal 10 Upkeep and Assist Service case ‘delete’ Drupal 10 Upkeep and Assist Service case ‘archive’ Drupal 10 Upkeep and Assist Service case ‘construct’ Drupal 10 Upkeep and Assist Service return $this->allowedIf($entityOrganizationMembership->hasPermission($operation . ‘ mission atmosphere’), ‘member doesn’t have “‘ . $operation . ‘ mission atmosphere” permission’); } // Unknown operation, no opinion. return AccessResult Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist Serviceneutral(‘No operation matches discovered for operation Drupal 10 Upkeep and Assist Service ‘ . $operation); As you might need seen, usually if you load a Consumer you don’t get a getActiveMembership() technique. However we prolonged Drupal Development Company base Consumer class and added it there. We additionally set that new class as Drupal Development Company default class for Drupal Development Company Consumer entity, which is definitely very simple Drupal 10 Upkeep and Assist Service operate hook_entity_type_build(&$entity_types) { if (isset($entity_types[‘user’])) { $entity_types[‘user’]->setClass(‘my_Drupal 10 moduleEntityUser); } } Now loading a person returns an occasion of our personal class. For createAccess() issues get trickier, as a result of at that time Drupal Development Company entity doesn’t exist but.This makes it not possible to examine if it’s a part of Drupal Development Company right group (or on this case, Drupal Development Company right mission, which is in flip a part of a company). So right here we’ll must additionally implement a subject degree Constraint on Drupal Development Company associated mission subject. This text explains how you can create a subject degree Constraint. On this Constraint we will do our Membership Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServicecheckIfAccountIsPartOfCorrectOrganization examine and make sure no person will be capable of save an atmosphere to a mission for a company they aren’t part of, regardless if they’re creating one or saving one (by some means having bypassed our entry examine). To make doubly certain, we additionally set Drupal Development Company $validationRequired property on our Surroundings class to true. This fashion entities will at all times demand to be validated first. If they aren’t, or they’ve errors, an exception can be thrown. Now we will lastly construct our relaxation useful resource. Since a Jenkins construct doesn’t exist as a customized entity inside JennyB (but), we create a customized REST useful resource. We use console for this and set Drupal Development Company canonical path to “/api/project_environment/{project_environment}/construct/{id}” and Drupal Development Company “create” path to “/api/project_environment/{project_environment}/construct”. We then create one other useful resource and set that one’s canonical to “/api/project_environment/{project_environment}/construct”, Drupal Development Company identical as our first useful resource’s “create” path. This fashion, if you POST to that path you set off a brand new construct and if you GET you obtain a listing of all builds for that atmosphere. We’ve got to separate this off into two sources, as a result of every useful resource can solely use every technique as soon as. We generate these sources utilizing console. However earlier than we will start with our logic correct, we’ve to ensure Drupal Development Company ProjectEnvironment entity will get robotically loaded. For this we have to lengthen Drupal Development Company routes technique from Drupal Development Company mother or father class. public operate routes() { $assortment = mother or father Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist Serviceroutes(); // add our paramconverter to all routes in Drupal Development Company assortment // if we may solely add choices to a couple routes, we’d have // to loop over $collection->all() and add them to particular ones. // Internally, that’s precisely what Drupal Development Company addOptions technique does anyway $choices[‘parameters’][‘project_environment’] = [ ‘type’ => ‘entity Drupal 10 Maintenance and Support Serviceproject_environment’, ‘converter’ => ‘paramconverter.entity’ ]; $collection->addOptions($choices); return $assortment; } In Drupal Development Company routes technique you may add or take away choices and necessities to your coronary heart’s content material. No matter you may usually do in a routes.yml file, you can too do right here. We have defined this in additional element on this weblog submit. Let’s take a more in-depth have a look at our create path. First we’ll want to ensure Drupal Development Company person is allowed to construct. Fortunately due to our customized entry handler that is very simple. // examine if person can construct $entity_access = $projectEnvironment->entry(‘construct’, NULL, TRUE); if (!$entity_access->isAllowed()) { // if it’s not allowed, we all know it’s a forbidden or impartial response which implements Drupal Development Company Cause interface. throw new AccessDeniedHttpException($entity_access->getReason()); } Now we will ask James to set off Drupal Development Company construct. // Speak to James $information[‘key’] = self Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceVALIDATION_KEY; $url = self Drupal 10 Upkeep and Assist Service Drupal 10 Upkeep and Assist ServiceAPI_URL . ‘/mission/’ . $projectEnvironment->getProject() ->getRemoteProjectID() . ‘/atmosphere/’ . $projectEnvironment->getRemoteEnvironmentID() . ‘/construct’; $response = $this->httpClient->request(‘POST’, $url, array(‘json’ => $information)); $responseData = json_decode($response->getBody()->getContents(), TRUE); For this check we use a easy key that James makes use of for authentication and construct Drupal Development Company URL in our REST useful resource. Finally this half can be moved to a library and Drupal Development Company code may look one thing like this Drupal 10 Upkeep and Assist Service $remoteProjectID = $projectEnvironment->getProject()->getRemoteProjectID(); $remoteEnvironmentID = $projectEnvironment->getRemoteEnvironmentID(); $response = $this->jamesConnection->triggerNewBuild($remoteProjectID, $remoteEnvironmentID, $information); $responseData = json_decode($response->getBody()->getContents(), TRUE); We examine Drupal Development Company information we get again and if every part has gone effectively, we will replace our native ProjectEnvironment entity with Drupal Development Company new at present deployed department. if ($response->getStatusCode() == 200 && $information[‘key’] !== $projectEnvironment->getCurrentlyDeployedBranch()) { // The whole lot went effective, so additionally replace Drupal Development Company $projectEnvironment to replicate what // Drupal Development Company at present deployed department is $projectEnvironment->setCurrentlyDeployedBranch($information[‘branch’]); // validate Drupal Development Company entity $violations = $projectEnvironment->validate(); foreach ($violations as $violation) { $errors[] = $violation->getMessage(); } if (isset($errors)) { throw new BadRequestHttpException(“Entity save validation errors Drupal 10 Upkeep and Assist Service ” . implode(“n”, $errors)); } // put it aside $projectEnvironment->save(); } Operating validate is important, as a result of we set Drupal Development Company $validationRequired property to TRUE for our entity sort. If one thing goes fallacious, together with our customized Constraints, we throw a Unhealthy Request exception and output Drupal Development Company validation errors. Then we merely return what James gave us. return new ResourceResponse($responseData, $response->getStatusCode()); On James’ finish, it’s principally Drupal Development Company identical however as a substitute of checking customized entry handlers, we (for now) simply validate Drupal Development Company key. And James in flip calls Jenkins’ API. This can even change, and James will hand off Drupal Development Company construct set off to RabbitMQ. However for Drupal Development Company objective of this check, we talk with Jenkins immediately. James then returns Drupal Development Company ID of Drupal Development Company newly triggered construct to JennyB, who returns it to JennyA. JennyA then makes use of that ID to name JennyB’s canonical Construct route with Drupal Development Company given ID till success or failure has occurred.   Curious to learn extra fascinating -related tidbits? Take a look at Drupal Development Company remainder of our weblog. Or just keep updated each three months and subscribe to our e-newsletter! Drupal 10 Improvement and Assist

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Dropsolid Drupal 10 Upkeep and Assist Service James & Jenny, our toolbox for sooner development

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.