Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to schedule publication state programmatically? #144

Open
xtul9 opened this issue Aug 15, 2024 · 0 comments
Open

How to schedule publication state programmatically? #144

xtul9 opened this issue Aug 15, 2024 · 0 comments

Comments

@xtul9
Copy link

xtul9 commented Aug 15, 2024

Hi, I have a (probably niche) use case - I need to set publication date of an entity within my own plugin's service.

I don't understand how to do that. I figured out that if I want to publish or un-publish an entity, I can just utilize publish service like so:

const QUIZ = 'plugin::quiz.quiz';

export default ({ strapi }: { strapi: Strapi }) => ({
  saveQuiz: withTryCatch(async (body: any): Promise<ServiceResponse<any>> => {
    const { quiz }: { quiz: Quiz } = body;

    const { publish } = strapi.plugin('publisher').service('publicationService');

    // Save the quiz
    const savedQuiz = await strapi.entityService!.create(QUIZ, { data: quiz });
    
    // Publish the quiz
    await publish(QUIZ, savedQuiz.id);
    
    // ...
  }),
});

But I've been browsing the code and I still can't figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant