Questions tagged [services]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
6 votes
2 answers
183 views

Craft loses contact with database, and stops daemon

Somehow the queue/listen occasionally loses access to the database: FATAL Exited too quickly . Database Connection Error: Craft CMS can’t connect to the database. As the connection is lost, it ...
Eddie's user avatar
  • 61
1 vote
1 answer
56 views

Job queue always failed to sync data into api/graphql with Getting unknown property of service

i have build a module to send entry value into a graphql mutation. so far running and succesfully, now with craft 4 (actually as 4.4.0), i plan to use job queue of craft. i add into queue before sync ...
Arham's user avatar
  • 11
1 vote
1 answer
44 views

Entry Query: How to load an entry with the full URL as only criterion

From PHP (Plugin), how can I load a certain entry if only the full URL is provided? I can not find Craft's logic in PHP to split the full URL into the site's baseUrl and the entry's URI. Please note ...
Matthias Redl-Mann's user avatar
1 vote
1 answer
407 views

Is it possible to access a Craft service directly from a Twig template?

Before attempting to perform an asset transform to an AVIF or WEBP format, I'd like to use Craft's Images service to determine if the server actually supports either of those formats like so: <...
jrrdnx's user avatar
  • 153
2 votes
1 answer
958 views

Migrating Server - Craft isn't installed yet

I've set up a new Forge server and connected the repo to my site. I've also uploaded the database and copied over the db credentials to the dotenv file. However when I visit the site control panel ...
CreateSean's user avatar
  • 1,963
3 votes
1 answer
1k views

Craft 3: how to call methods in another plugin's service?

In Craft 2, we used to be able to do so by doing: craft()->plugin1->myMethod(); from Plugin 2's service for example. Now in Craft 3, I couldn't figure out a way to do it. Plugin1::$plugin-&...
Wei's user avatar
  • 459
1 vote
1 answer
978 views

Install Zoho CRM SDK (or any SDK for that matter)

For a client I need to connect a rather complex contact form with the Zoho CRM. They're offering a PHP SDK which sounds great, but I can't get it to work. It's very likely that I'm just stupid, ...
Robert Cordes's user avatar
1 vote
1 answer
357 views

"Unknown "craft" function" Error in Plugin Service Call

I'm just starting with plugins and I've downloaded the Business Logic plugin and am trying to call it from my template. Here's the code in my template: {% extends "_layout" %} {% block content %} ...
buck1112's user avatar
  • 400
1 vote
0 answers
748 views

Unable to call a service method from controller in my custom plugin

I know there are similar questions here, but I don't see a definitive answer, nor one that works for me. I've generated a plugin via pluginfactory.io, which has some controllers and a single service. ...
Derek Hogue's user avatar
1 vote
1 answer
52 views

Craft plugin services in subfolders

So I'm getting to a point where I have a lot of services in a particular plugin, and I would like to organize my plugin services into sub-folders. I've tried a couple ways but the controllers don't ...
Manny's user avatar
  • 25
2 votes
1 answer
929 views

Craft 3: How to get Volume by handle?

How can I get the details of an asset volume in Craft 3, if I only know the handle? I found the Volumes and the Assets service, but I believe none of them provides a method for that purpose. The only ...
Matthias Redl-Mann's user avatar
1 vote
1 answer
73 views

Changing asset of entry's assetfield via entries.onBeforeSaveEntry

I'm trying to add an asset to an entry's assetfield when the entry is saved by using the onBeforeSaveEntry service provided by Craft. craft()->on('entries.onBeforeSaveEntry', function(Event $event)...
justussimon91's user avatar
3 votes
1 answer
105 views

Tech Support-Provider for Craft CMS

we are a small team in Berlin, Germany, developing editorial websites based on craft cms. A major publishing house is interested in our services. A condition to get contracted is us to provide a ...
Reinhard's user avatar
  • 101
2 votes
1 answer
48 views

Loading dynamically-named classes in a plugin's service

I'm in the process of building a plugin that'll have extensible 'Providers' to allow developers to build connections to other services. These 'Providers' will just be classes that are built to an ...
Taylor Daughtry's user avatar
0 votes
1 answer
386 views

How to handle entry save in plugin when entryId is not set?

Referring to my older question, I have the entryId working on an existing entry. However I've noticed a new entry doesn't have an entryId set (makes sense). I have some custom information in text ...
iNalgiev's user avatar
1 vote
1 answer
281 views

Need a way to connect to a webservice

I have a lot of data that sits outside of Craft (the data is in MS SQL Server) and I plan on writing a simple .NET Service which will return JSON. I need to display this data but not sure on how to ...
Subrato M's user avatar
  • 109
2 votes
1 answer
1k views

How do I call a service from my controller in a plugin?

I'm writing a plugin, and used plugin.io to generate my scaffolding. In my controller I am attempting to call a service, and getting an error. This is my service code from my generated plugin it ...
danieltalsky's user avatar
1 vote
1 answer
59 views

Getting database error when calling CateogoryService method

I have a PHP file in the public_html titled categories.php with the following code: namespace Craft; $craft = require '../craft/app/bootstrap.php'; $categories = $craft->categories->...
jGaiser's user avatar
  • 35
1 vote
1 answer
585 views

Update multiple database entries via controller

I've inherited a Craft site that is a mix of a custom plugin (the main site) plus a Laravel Dingo plugin (behind which the bulk of the data in the db lives), plus Solr, and I'm trying to untangle it. ...
OrdinaryHuman's user avatar
1 vote
1 answer
315 views

Listen to onSetStatus event

I wanted to listen to the onSetStatus event of the SetStatusElementAction and used the same code like in the EntryElementType class: $setStatusAction = craft()->elements->getAction('SetStatus');...
oncode's user avatar
  • 220
1 vote
1 answer
196 views

saveEntry() not firing

I'm using code I've been using to update existing entries for a while now and it's failing to fire following the 2.5 upgrade. Trying to figure out what might have changed, or if there's something I'm ...
Mark J. Reeves's user avatar
2 votes
2 answers
58 views

How do I make a service only runable by the server?

I've created an action that calls a service. The action will be called by a cron task. I want to set this up so that ONLY the cron task can call the action. It's important that it can not be run by ...
H2ONOCK's user avatar
  • 231
0 votes
2 answers
2k views

Using Services to get all the Categories related to an Entry?

In a plugin, I've been advised to try to use craft built-in services instead of direct db queries. So can anyone help with this: For an entry type that includes a categories field, how to get all the ...
kr37's user avatar
  • 1,355
2 votes
1 answer
797 views

How to catch errors in a service and return to a controller?

How do you handle “catching” errors in a plugin service and return the error to the plugins controller? To be more specific... I am sending an Ajax request to a controller, that controller is ...
Jason McCallister's user avatar
3 votes
1 answer
799 views

Inserting multiple records in a plugin

I'm building a plugin and have a form in the plugin's CP page that allows admins to save access codes. The form is a simple textarea where each line is a separate access code. I'm wondering what the ...
Brett DeWoody's user avatar
2 votes
1 answer
140 views

Using services/records etc in migrations

The database migrations documentation does say: Please note that we do not recommend using records directly within a migration Are there technical reasons for this recommendation, or is it ...
Mike Pepper's user avatar
  • 4,391
3 votes
1 answer
818 views

How to tell if user exists

I am automatically creating users in a service, is there a way to check if user exists? I want to log in id user exist or save a new user if it doesn't, I have the following so far which will add a ...
ConquestXD's user avatar
2 votes
1 answer
897 views

Plugin Settings: Attribute Types, and how to receive

I have two small arrays I want to store in my plugin settings, though I'm stuck at what the AttributeType:: should be, as well as how to retrieve the actual values. The arrays I want to store look ...
taylor's user avatar
  • 1,128
2 votes
1 answer
1k views

Issues with Twig template includes when rendering from a service called from a CP-triggered event

I have a listener for the entries.saveEntryevent that is calling a service, which generates an email from a rendered template. The template is attempting to import macros. MyaddonPlugin.php::init() ...
Nick Le Guillou's user avatar
1 vote
0 answers
50 views

An extra event upon usergroup assignment onAssignUserToGroup [closed]

I have come across a scenario where I need an event like "onAssignUserToGroup". This is purely for a client request and to modify functionality in the backend CP for my plugin, but this is the second ...
Moin Qidwai's user avatar
6 votes
3 answers
2k views

setContent() vs $entry->getContent()->foo

I'm a bit confused about the usage of these two. Let's say I want to create a new entry from a controller. For me, the nicer option would be to user something like this: $entry = new EntryModel(); $...
Sidney Widmer's user avatar
5 votes
2 answers
2k views

Populate a record with a model?

In a follow up to my earlier question, I'm focusing on cleaning up my code to keep it incredibly simple. I've moved on from the Controller and Model to the Model and Service. Typically you would have ...
Jason McCallister's user avatar
1 vote
1 answer
332 views

MVC - Should these be seperate controllers/models etc

I hope this is the right place to post this, it's more a question on MVC for plugin development. I'm developing a plugin to extend SproutForms to add users to Campaign Monitor lists. So far I've got ...
KeironLowe's user avatar
3 votes
1 answer
1k views

Service not defined

I'm trying to build my first plugin using a service but i can't seem to get it to work. The file is named CampaignReports_CampaignMonitorService.php and it's in the services folder of my plugin. ...
Steven Vandemoortele's user avatar
2 votes
1 answer
774 views

How can I use a session consistently in a service and variable?

I’m working on a simple cart and trying to utilize the user session id to keep track of things. The session getting saved to the database doesn't match the session that’s being displayed in ...
Anson LeClair's user avatar
6 votes
1 answer
724 views

Allow anonymous submission on a custom element type?

I have a custom element type that I want to allow anonymous submission from the front-end. I have a solid concept on how the form data is passed but I seem to be missing something. I have the ...
Jason McCallister's user avatar
2 votes
1 answer
1k views

Whats the best way to save a new entry in my plugin?

I have a channel section by the name of order. What I need is that every time a user clicks a button on the front end the data of the form is sent to my plugin which then uses the data to create a new ...
Moin Qidwai's user avatar
1 vote
1 answer
424 views

Error when calling methods between two services (triggered by init)

I have two Services in my plugin. MyPluginService is the "main" service, and MyPlugin_OtherService accomplishes some other tasks (when it is occasionally needed). There is an init method in ...
Lindsey D's user avatar
  • 24k